lang: Print a clear message on module import containing unused stmt

If you run an import, you only include everything that's part of a
scope. This includes, variables, classes, and functions. Anything else
should cause a compile error. This cleans up the error by adding a
String() method to each Stmt in our AST.
This commit is contained in:
James Shubin
2019-02-28 09:35:13 -05:00
parent 94c40909cc
commit 829741e2ac
5 changed files with 73 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ type Node interface {
// expression.)
type Stmt interface {
Node
fmt.Stringer // String() string
Init(*Data) error // initialize the populated node and validate
Interpolate() (Stmt, error) // return expanded form of AST as a new AST
SetScope(*Scope) error // set the scope here and propagate it downwards
@@ -54,6 +55,7 @@ type Stmt interface {
// these can be stored as pointers in our graph data structure.
type Expr interface {
Node
//fmt.Stringer // already provided by pgraph.Vertex
pgraph.Vertex // must implement this since we store these in our graphs
Init(*Data) error // initialize the populated node and validate
Interpolate() (Expr, error) // return expanded form of AST as a new AST