Skip to content

Commit

Permalink
Reset tracking of applied operator overloads before every walk of the…
Browse files Browse the repository at this point in the history
… ast tree.
  • Loading branch information
rrb3942 committed May 22, 2024
1 parent 596f54f commit 3a27060
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,22 @@ func ParseCheck(input string, config *conf.Config) (*parser.Tree, error) {
// types information available in the tree.
_, _ = Check(tree, config)

r, repeatable := v.(interface {
Reset()
ShouldRepeat() bool
});

if repeatable {
r.Reset()
}

ast.Walk(&tree.Node, v)

if v, ok := v.(interface {
ShouldRepeat() bool
}); ok {
more = more || v.ShouldRepeat()
if repeatable {
more = more || r.ShouldRepeat()
}
}

if !more {
break
}
Expand Down
5 changes: 5 additions & 0 deletions patcher/operator_override.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func (p *OperatorOverloading) Visit(node *ast.Node) {
}
}

// Tracking must be reset before every walk over the AST tree
func (p *OperatorOverloading) Reset() {
p.applied = false
}

func (p *OperatorOverloading) ShouldRepeat() bool {
return p.applied
}
Expand Down

0 comments on commit 3a27060

Please sign in to comment.