Skip to content

Commit 8eb6e10

Browse files
committed
RA22-015: Add test for calls to non callable entities
1 parent 3035409 commit 8eb6e10

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Error for trying to call a non callable
2+
3+
val a: (Int) -> Int = null
4+
@invalid val b: Int = a(12)()
5+
6+
fun c(i: Int): Int = i + 2
7+
@invalid val d: Int = a(12)()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Resolving test.lkt
2+
==================
3+
Id <RefId "Int" test.lkt:3:9-3:12>
4+
references <StructDecl prelude: "Int">
5+
6+
Id <RefId "Int" test.lkt:3:17-3:20>
7+
references <StructDecl prelude: "Int">
8+
9+
Expr <NullLit test.lkt:3:23-3:27>
10+
has type <FunctionType prelude: "(Int) -> Int">
11+
12+
Id <RefId "Int" test.lkt:4:17-4:20>
13+
references <StructDecl prelude: "Int">
14+
15+
test.lkt:4:23: error: Object of type `Int` is not callable
16+
3 | @invalid val b: Int = a(12)()
17+
| ^^^^^
18+
19+
Id <RefId "a" test.lkt:4:23-4:24>
20+
references <ValDecl "a" test.lkt:3:1-3:27>
21+
22+
Expr <RefId "a" test.lkt:4:23-4:24>
23+
has type <FunctionType prelude: "(Int) -> Int">
24+
25+
Expr <NumLit test.lkt:4:25-4:27>
26+
has type <StructDecl prelude: "Int">
27+
28+
Expr <CallExpr test.lkt:4:23-4:28>
29+
has type <StructDecl prelude: "Int">
30+
31+
Expr <CallExpr test.lkt:4:23-4:30>
32+
has type <StructDecl prelude: "Int">
33+
34+
Id <RefId "Int" test.lkt:6:10-6:13>
35+
references <StructDecl prelude: "Int">
36+
37+
Id <RefId "Int" test.lkt:6:16-6:19>
38+
references <StructDecl prelude: "Int">
39+
40+
Id <RefId "i" test.lkt:6:22-6:23>
41+
references <FunArgDecl "i" test.lkt:6:7-6:13>
42+
43+
Expr <RefId "i" test.lkt:6:22-6:23>
44+
has type <StructDecl prelude: "Int">
45+
46+
Expr <NumLit test.lkt:6:26-6:27>
47+
has type <StructDecl prelude: "Int">
48+
49+
Expr <BinOp test.lkt:6:22-6:27>
50+
has type <StructDecl prelude: "Int">
51+
52+
Id <RefId "Int" test.lkt:7:17-7:20>
53+
references <StructDecl prelude: "Int">
54+
55+
test.lkt:7:23: error: Object of type `Int` is not callable
56+
6 | @invalid val d: Int = a(12)()
57+
| ^^^^^
58+
59+
Id <RefId "a" test.lkt:7:23-7:24>
60+
references <ValDecl "a" test.lkt:3:1-3:27>
61+
62+
Expr <RefId "a" test.lkt:7:23-7:24>
63+
has type <FunctionType prelude: "(Int) -> Int">
64+
65+
Expr <NumLit test.lkt:7:25-7:27>
66+
has type <StructDecl prelude: "Int">
67+
68+
Expr <CallExpr test.lkt:7:23-7:28>
69+
has type <StructDecl prelude: "Int">
70+
71+
Expr <CallExpr test.lkt:7:23-7:30>
72+
has type <StructDecl prelude: "Int">
73+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
driver: lkt

0 commit comments

Comments
 (0)