Skip to content

Commit

Permalink
Printing error origin during compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
lock9 committed Jan 6, 2025
1 parent 4d2b88d commit 9713b67
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/compiler/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,8 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
case *ast.StarExpr:
_, ok := c.getStruct(c.typeOf(n.X))
if !ok {
c.prog.Err = errors.New("dereferencing is only supported on structs")
pos := c.buildInfo.config.Fset.Position(n.Pos())
c.prog.Err = fmt.Errorf("%s: dereferencing is only supported on structs", pos)

Check warning on line 917 in pkg/compiler/codegen.go

View check run for this annotation

Codecov / codecov/patch

pkg/compiler/codegen.go#L916-L917

Added lines #L916 - L917 were not covered by tests
return nil
}
ast.Walk(c, n.X)
Expand Down Expand Up @@ -1158,7 +1159,8 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
c.convertStruct(lit, true)
return nil
}
c.prog.Err = fmt.Errorf("'&' can be used only with struct literals")
pos := c.buildInfo.config.Fset.Position(n.Pos())
c.prog.Err = fmt.Errorf("%s: '&' can be used only with struct literals", pos)

Check warning on line 1163 in pkg/compiler/codegen.go

View check run for this annotation

Codecov / codecov/patch

pkg/compiler/codegen.go#L1162-L1163

Added lines #L1162 - L1163 were not covered by tests
return nil
}

Expand Down

0 comments on commit 9713b67

Please sign in to comment.