Skip to content

Commit

Permalink
RA22-015: Add test for calls to non callable entities
Browse files Browse the repository at this point in the history
  • Loading branch information
raph-amiard committed Sep 30, 2021
1 parent 3035409 commit 8eb6e10
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Error for trying to call a non callable

val a: (Int) -> Int = null
@invalid val b: Int = a(12)()

fun c(i: Int): Int = i + 2
@invalid val d: Int = a(12)()
73 changes: 73 additions & 0 deletions testsuite/tests/contrib/lkt_semantic/call_non_callable/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Resolving test.lkt
==================
Id <RefId "Int" test.lkt:3:9-3:12>
references <StructDecl prelude: "Int">

Id <RefId "Int" test.lkt:3:17-3:20>
references <StructDecl prelude: "Int">

Expr <NullLit test.lkt:3:23-3:27>
has type <FunctionType prelude: "(Int) -> Int">

Id <RefId "Int" test.lkt:4:17-4:20>
references <StructDecl prelude: "Int">

test.lkt:4:23: error: Object of type `Int` is not callable
3 | @invalid val b: Int = a(12)()
| ^^^^^

Id <RefId "a" test.lkt:4:23-4:24>
references <ValDecl "a" test.lkt:3:1-3:27>

Expr <RefId "a" test.lkt:4:23-4:24>
has type <FunctionType prelude: "(Int) -> Int">

Expr <NumLit test.lkt:4:25-4:27>
has type <StructDecl prelude: "Int">

Expr <CallExpr test.lkt:4:23-4:28>
has type <StructDecl prelude: "Int">

Expr <CallExpr test.lkt:4:23-4:30>
has type <StructDecl prelude: "Int">

Id <RefId "Int" test.lkt:6:10-6:13>
references <StructDecl prelude: "Int">

Id <RefId "Int" test.lkt:6:16-6:19>
references <StructDecl prelude: "Int">

Id <RefId "i" test.lkt:6:22-6:23>
references <FunArgDecl "i" test.lkt:6:7-6:13>

Expr <RefId "i" test.lkt:6:22-6:23>
has type <StructDecl prelude: "Int">

Expr <NumLit test.lkt:6:26-6:27>
has type <StructDecl prelude: "Int">

Expr <BinOp test.lkt:6:22-6:27>
has type <StructDecl prelude: "Int">

Id <RefId "Int" test.lkt:7:17-7:20>
references <StructDecl prelude: "Int">

test.lkt:7:23: error: Object of type `Int` is not callable
6 | @invalid val d: Int = a(12)()
| ^^^^^

Id <RefId "a" test.lkt:7:23-7:24>
references <ValDecl "a" test.lkt:3:1-3:27>

Expr <RefId "a" test.lkt:7:23-7:24>
has type <FunctionType prelude: "(Int) -> Int">

Expr <NumLit test.lkt:7:25-7:27>
has type <StructDecl prelude: "Int">

Expr <CallExpr test.lkt:7:23-7:28>
has type <StructDecl prelude: "Int">

Expr <CallExpr test.lkt:7:23-7:30>
has type <StructDecl prelude: "Int">

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
driver: lkt

0 comments on commit 8eb6e10

Please sign in to comment.