From b0ac74488c88a329ab76bdc649d3118b5ce2fcd3 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Mon, 13 Jan 2020 19:52:16 +0100 Subject: [PATCH] pass: "instruction should follow a label" info (#115) Add the label in question to the error message. --- pass/cfg.go | 2 +- pass/cfg_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pass/cfg.go b/pass/cfg.go index 198208d..d8e8fd4 100644 --- a/pass/cfg.go +++ b/pass/cfg.go @@ -17,7 +17,7 @@ func LabelTarget(fn *ir.Function) error { switch n := node.(type) { case ir.Label: if pending != empty { - return errors.New("instruction should follow a label") + return fmt.Errorf("expected instruction following label %q", pending) } pending = n if _, found := target[pending]; found { diff --git a/pass/cfg_test.go b/pass/cfg_test.go index 42f1004..5dc8857 100644 --- a/pass/cfg_test.go +++ b/pass/cfg_test.go @@ -66,7 +66,7 @@ func TestLabelTargetInstructionFollowLabel(t *testing.T) { 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) } }