You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type checker requires that the caller sort the rules topologically however for independent rules (p and q below) there is no ordering requirement (and the ordering for independent rules is currently non-deterministic.) This results in spurious undefined function errors. For example:
package x
p {
concat("", 1) # type error
}
q {
f(1)
}
f(x) = x
The spurious "undefined function" errors are emitted because the type checker does not update the type environment once it finds a single error AND the order that independent rules are checked in is non-deterministic. For example:
case 1:
f # no error, f added to type env
q # no error, q added to type env
p # concat type error, p not added to type env
case 2:
p # concat type error, p not added to type env
f # no error, but since checker contains error for p, f not added to type env
q # undefined function error since f not in type env
This is related to #2091 but not quite the same. It's possible that the solution for this issue could resolve #2091. For example, the type checker could be updated to add rules/functions to the type env EVEN IF they contain errors. Since the types of terms in the head of the rule can't be inferred reliably in this case, they could be added as ANY types. This would mean dependents of erroneous rules/functions would not encounter "undefined function" or "undefined ref" or other type errors. This would be nice because independent rules could still be type checked and we can report the maximum number of errors in one pass.
The text was updated successfully, but these errors were encountered:
Earlier if a rule/function contained an error, the type checker would not update the env with subsequent independent rules resulting in errors such as "undefined functions". This change add erroneous rules/functions to the env to avoid such type errors.
Fixesopen-policy-agent#2155Fixesopen-policy-agent#2091
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Earlier if a rule/function contained an error, the type checker would not update the env with subsequent independent rules resulting in errors such as "undefined functions". This change add erroneous rules/functions to the env to avoid such type errors.
Fixes#2155Fixes#2091
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
The type checker requires that the caller sort the rules topologically however for independent rules (
p
andq
below) there is no ordering requirement (and the ordering for independent rules is currently non-deterministic.) This results in spurious undefined function errors. For example:The spurious "undefined function" errors are emitted because the type checker does not update the type environment once it finds a single error AND the order that independent rules are checked in is non-deterministic. For example:
case 1:
case 2:
This is related to #2091 but not quite the same. It's possible that the solution for this issue could resolve #2091. For example, the type checker could be updated to add rules/functions to the type env EVEN IF they contain errors. Since the types of terms in the head of the rule can't be inferred reliably in this case, they could be added as ANY types. This would mean dependents of erroneous rules/functions would not encounter "undefined function" or "undefined ref" or other type errors. This would be nice because independent rules could still be type checked and we can report the maximum number of errors in one pass.
The text was updated successfully, but these errors were encountered: