3500c686b3
- add type infos to VM error messages - add 'Name' to UserFunction objects - add 'expectErrorString' to VM tests - replace vm.expectError() with vm.expectErrorString() to make it more explicit - add source map info to VM error messages - optimization in function calls - add file/line/col info to compiler errors - change stdlib module to be loaded from VM (instead of compiler) so they can be properly loaded after the source is compiled into binary - VM can take builtin modules optionally
20 lines
368 B
Go
20 lines
368 B
Go
package compiler
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/d5/tengo/compiler/ast"
|
|
"github.com/d5/tengo/compiler/source"
|
|
)
|
|
|
|
// Error represents a compiler error.
|
|
type Error struct {
|
|
fileSet *source.FileSet
|
|
node ast.Node
|
|
error error
|
|
}
|
|
|
|
func (e *Error) Error() string {
|
|
filePos := e.fileSet.Position(e.node.Pos())
|
|
return fmt.Sprintf("%s: %s", filePos, e.error.Error())
|
|
}
|