Skip to content

Commit

Permalink
fix bug in error reporting when const has non-const expression (#5389)
Browse files Browse the repository at this point in the history
Co-authored-by: Noah Treuhaft <[email protected]>
  • Loading branch information
mccanne and nwt authored Oct 30, 2024
1 parent 29bbea5 commit 22fed24
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/semantic/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *Scope) DefineConst(zctx *super.Context, name *ast.ID, def dag.Expr) err
}
if val.IsError() {
if val.IsMissing() {
return fmt.Errorf("const %q: cannot have variable dependency", name)
return fmt.Errorf("const %q: cannot have variable dependency", name.Name)
} else {
return fmt.Errorf("const %q: %q", name, string(val.Bytes()))
}
Expand Down
4 changes: 1 addition & 3 deletions compiler/ztests/const-err.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ input: |
{a:1}
{a:2}
output: ""

error: |
const &{"ID" "t" {'\x06' '\x06'}}: cannot have variable dependency at line 1, column 1:
const "t": cannot have variable dependency at line 1, column 1:
const t=a put x:=t
~~~~~~~~~

0 comments on commit 22fed24

Please sign in to comment.