pass: "instruction should follow a label" info (#115)
Add the label in question to the error message.
This commit is contained in:
committed by
Michael McLoughlin
parent
3c861c7c0b
commit
b0ac74488c
@@ -17,7 +17,7 @@ func LabelTarget(fn *ir.Function) error {
|
|||||||
switch n := node.(type) {
|
switch n := node.(type) {
|
||||||
case ir.Label:
|
case ir.Label:
|
||||||
if pending != empty {
|
if pending != empty {
|
||||||
return errors.New("instruction should follow a label")
|
return fmt.Errorf("expected instruction following label %q", pending)
|
||||||
}
|
}
|
||||||
pending = n
|
pending = n
|
||||||
if _, found := target[pending]; found {
|
if _, found := target[pending]; found {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func TestLabelTargetInstructionFollowLabel(t *testing.T) {
|
|||||||
|
|
||||||
err := LabelTarget(f)
|
err := LabelTarget(f)
|
||||||
|
|
||||||
if err == nil || err.Error() != "instruction should follow a label" {
|
if err == nil || err.Error() != "expected instruction following label \"lblA\"" {
|
||||||
t.Fatalf("expected error when label is not followed by instruction; got %v", err)
|
t.Fatalf("expected error when label is not followed by instruction; got %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user