From 4d30772b3b455619c5dac539ab5d2c471df381ec Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 28 Nov 2024 19:17:33 -0500 Subject: [PATCH] lang: Add test for unused include statements Even if they have no side effect, they aren't legal, since it would be surprising if suddenly something new got added in one which then broke the imports. --- .../interpret_test/TestAstFunc1/unused2.txtar | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lang/interpret_test/TestAstFunc1/unused2.txtar diff --git a/lang/interpret_test/TestAstFunc1/unused2.txtar b/lang/interpret_test/TestAstFunc1/unused2.txtar new file mode 100644 index 00000000..7363c5f7 --- /dev/null +++ b/lang/interpret_test/TestAstFunc1/unused2.txtar @@ -0,0 +1,19 @@ +-- main.mcl -- +import "fmt" +import "something.mcl" + +print "p1" { + msg => fmt.printf("someint: %d", $something.someint), +} +-- something.mcl -- +$someint = 42 +class someclass { + print "p2" { + msg => "i'm inside of someclass", + } +} + +# this should generate a compile error +include someclass +-- OUTPUT -- +# err: errSetScope: local import of `something.mcl` failed: module contains unused statements: found stmt: include(someclass)