Skip to content

Commit

Permalink
lang: Add test for unused include statements
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
purpleidea committed Nov 29, 2024
1 parent 8472b1e commit 4d30772
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lang/interpret_test/TestAstFunc1/unused2.txtar
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4d30772

Please sign in to comment.