mirror of
https://github.com/RoBaertschi/tt.git
synced 2025-04-18 23:13:29 +00:00
fix: typechecker error handling
- rename Architecture.md -> architecture.md - change error handling in typechecker to print the token loc for binary expressions and also not prefix the error when printed in cmd
This commit is contained in:
parent
ab7e332ac4
commit
6504ad7134
@ -128,7 +128,7 @@ func Compile(args Arguments) {
|
|||||||
|
|
||||||
tprogram, err := typechecker.New().CheckProgram(program)
|
tprogram, err := typechecker.New().CheckProgram(program)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Typechecker failed with: %v\n", err)
|
fmt.Printf("%v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if (args.ToPrint & PrintTAst) != 0 {
|
if (args.ToPrint & PrintTAst) != 0 {
|
||||||
|
@ -78,9 +78,9 @@ func (c *Checker) checkExpression(expr tast.Expression) error {
|
|||||||
var operandErr error
|
var operandErr error
|
||||||
if lhsErr == nil && rhsErr == nil {
|
if lhsErr == nil && rhsErr == nil {
|
||||||
if !expr.Lhs.Type().IsSameType(expr.Rhs.Type()) {
|
if !expr.Lhs.Type().IsSameType(expr.Rhs.Type()) {
|
||||||
operandErr = fmt.Errorf("the lhs of the expression does not have the same type then the rhs, lhs=%q, rhs=%q", expr.Lhs.Type().Name(), expr.Rhs.Type().Name())
|
operandErr = c.error(expr.Token, "the lhs of the expression does not have the same type then the rhs, lhs=%q, rhs=%q", expr.Lhs.Type().Name(), expr.Rhs.Type().Name())
|
||||||
} else if !expr.Lhs.Type().SupportsBinaryOperator(expr.Operator) {
|
} else if !expr.Lhs.Type().SupportsBinaryOperator(expr.Operator) {
|
||||||
operandErr = fmt.Errorf("the operator %q is not supported by the type %q", expr.Operator, expr.Lhs.Type().Name())
|
operandErr = c.error(expr.Token, "the operator %q is not supported by the type %q", expr.Operator, expr.Lhs.Type().Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user