Improved assignment error message

This commit is contained in:
Eduard Urbach 2024-07-05 09:50:46 +02:00
parent 3340a5824f
commit 62057704f3
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -61,7 +61,7 @@ func toASTNode(tokens token.List) (Node, error) {
switch { switch {
case IsVariableDefinition(expr): case IsVariableDefinition(expr):
if len(expr.Children) < 2 { if len(expr.Children) < 2 {
return nil, errors.New(errors.MissingAssignValue, nil, expr.LastChild().Token.End()) return nil, errors.New(errors.MissingAssignValue, nil, expr.Token.End())
} }
name := expr.Children[0].Token name := expr.Children[0].Token
@ -70,7 +70,7 @@ func toASTNode(tokens token.List) (Node, error) {
case IsAssignment(expr): case IsAssignment(expr):
if len(expr.Children) < 2 { if len(expr.Children) < 2 {
return nil, errors.New(errors.MissingAssignValue, nil, expr.LastChild().Token.End()) return nil, errors.New(errors.MissingAssignValue, nil, expr.Token.End())
} }
name := expr.Children[0].Token name := expr.Children[0].Token