Improved error message for invalid instructions
This commit is contained in:
parent
aec22b0a7e
commit
e4cbb91f61
@ -37,6 +37,6 @@ func parseNode(tokens token.List, source []byte, nodes AST) (Node, error) {
|
|||||||
return &Call{Expression: expr}, nil
|
return &Call{Expression: expr}, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, errors.New(&errors.InvalidInstruction{Instruction: expr.Token.Text(source)}, nil, expr.Token.Position)
|
return nil, errors.New(&errors.InvalidInstruction{Instruction: tokens.Text(source)}, nil, tokens[0].Position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
tests/errors/InvalidInstructionCall.q
Normal file
5
tests/errors/InvalidInstructionCall.q
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
main() {
|
||||||
|
sys.write
|
||||||
|
}
|
@ -22,7 +22,8 @@ var errs = []struct {
|
|||||||
{"ExpectedIfBeforeElse2.q", errors.ExpectedIfBeforeElse},
|
{"ExpectedIfBeforeElse2.q", errors.ExpectedIfBeforeElse},
|
||||||
{"ExpectedStructName.q", errors.ExpectedStructName},
|
{"ExpectedStructName.q", errors.ExpectedStructName},
|
||||||
{"ExpectedPackageName.q", errors.ExpectedPackageName},
|
{"ExpectedPackageName.q", errors.ExpectedPackageName},
|
||||||
{"InvalidInstructionExpression.q", &errors.InvalidInstruction{Instruction: "+"}},
|
{"InvalidInstructionCall.q", &errors.InvalidInstruction{Instruction: "sys.write"}},
|
||||||
|
{"InvalidInstructionExpression.q", &errors.InvalidInstruction{Instruction: "2+3"}},
|
||||||
{"InvalidInstructionIdentifier.q", &errors.InvalidInstruction{Instruction: "abc"}},
|
{"InvalidInstructionIdentifier.q", &errors.InvalidInstruction{Instruction: "abc"}},
|
||||||
{"InvalidInstructionNumber.q", &errors.InvalidInstruction{Instruction: "123"}},
|
{"InvalidInstructionNumber.q", &errors.InvalidInstruction{Instruction: "123"}},
|
||||||
{"InvalidInstructionString.q", &errors.InvalidInstruction{Instruction: "\"Hello\""}},
|
{"InvalidInstructionString.q", &errors.InvalidInstruction{Instruction: "\"Hello\""}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user