Skip to content

Commit d337a3d

Browse files
pmderodatraph-amiard
authored andcommitted
Symbolic solver: never raise Early_Binding_Error exceptions
The very way the symbolic solver works (topological sorting, often on partial lists of atoms, stopping atoms collections early) prevents most opportunities to detect equations that are malformed wrt. data flow. To avoid API predictability, just never raise Early_Binding_Error exceptions and always consider a missing variable definition as a "false" solution. TN: SB20-024
1 parent e90d03f commit d337a3d

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

support/langkit_support-adalog-symbolic_solver.adb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,24 +1903,17 @@ package body Langkit_Support.Adalog.Symbolic_Solver is
19031903

19041904
Ret : Boolean;
19051905
begin
1906-
-- If the logic variable that ``Self`` uses is not defined, raise an
1907-
-- error.
1906+
-- Do not even try to evaluate this atom if it uses a variable that is
1907+
-- not defined at this point.
19081908
--
19091909
-- Note that this cannot happen when called from ``Solve_Compound`` as
19101910
-- the topological sort makes sure all variables are defined before they
19111911
-- are used (and abort the resolution if it is not possible), so the
19121912
-- condition below will succeed only when ``Solve_Atomic`` is called
19131913
-- from ``Solve`` when called on an atom directly.
1914-
--
1915-
-- TODO??? Maybe we should always go through ``Solve_Compound`` to avoid
1916-
-- this redundant check, and more generally have a unique way to solve
1917-
-- relations, and unique way to deal with errors (return no solution
1918-
-- or raise ``Early_Binding_Error``.
1914+
19191915
if not Is_Defined_Or_Null (Used_Var (Atom)) then
1920-
raise Early_Binding_Error with
1921-
"Relation " & Image (Atom)
1922-
& " needs var " & Image (Used_Var (Atom).Logic_Var)
1923-
& " to be defined";
1916+
return False;
19241917
end if;
19251918

19261919
case Atom.Kind is

0 commit comments

Comments
 (0)