Skip to content

Commit

Permalink
Remove hasdynamicvalue function calls from rulenode2expr functions …
Browse files Browse the repository at this point in the history
…because they cause issues with using `_val` as an evaluation cache for the Probe algorithm.
nicolaefilat committed Jul 5, 2024
1 parent aca61f9 commit 93bec01
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rulenode_operators.jl
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ function rulenode2expr(rulenode::AbstractRuleNode, grammar::AbstractGrammar)
if !isfilled(rulenode)
return _get_hole_type(rulenode, grammar)
end
root = hasdynamicvalue(rulenode) ? rulenode._val : deepcopy(grammar.rules[get_rule(rulenode)])
root = deepcopy(grammar.rules[get_rule(rulenode)])
if !grammar.isterminal[get_rule(rulenode)] # not terminal
root,_ = _rulenode2expr(root, rulenode, grammar)
end
@@ -183,7 +183,7 @@ function _rulenode2expr(expr::Expr, rulenode::AbstractRuleNode, grammar::Abstrac
elseif haskey(grammar.bytype, arg)
child = rulenode.children[j+=1]
if isfilled(child)
expr.args[k] = hasdynamicvalue(child) ? child._val : deepcopy(grammar.rules[get_rule(child)])
expr.args[k] = deepcopy(grammar.rules[get_rule(child)])
if !isterminal(grammar, child)
expr.args[k],_ = _rulenode2expr(expr.args[k], child, grammar, 0)
end
@@ -202,7 +202,7 @@ function _rulenode2expr(typ::Symbol, rulenode::AbstractRuleNode, grammar::Abstra
retval = typ
if haskey(grammar.bytype, typ)
child = rulenode.children[1]
retval = hasdynamicvalue(rulenode) ? child._val : deepcopy(grammar.rules[get_rule(child)])
retval = deepcopy(grammar.rules[get_rule(child)])

Check warning on line 205 in src/rulenode_operators.jl

Codecov / codecov/patch

src/rulenode_operators.jl#L205

Added line #L205 was not covered by tests
if !grammar.isterminal[get_rule(child)]
retval,_ = _rulenode2expr(retval, child, grammar, 0)
end

0 comments on commit 93bec01

Please sign in to comment.