Hey,
I’ve stumbled upon an unexpected compile time error that I’ve tracked down to what seems to be an edge case issue in DCG expansion.
To reproduce, load the following lines in SWI-Prolog:
% Works as expected: no warnings
good_dcg_bound_meta_call --> { Goal = true, Goal }.
% Works as expected: Singleton variables: [Goal]
good_dcg_unbound_meta_call --> { call(Goal) }.
% Unexpected: ERROR: Type error: `callable' expected, found `_13178,_13184=_13186' (a compound)
bad_dcg_unbound_meta_call --> { Goal }.
Reproduces on Mac OS with version 8.3.28 and on ubuntu with version 8.2.4, so it seems like this issue exists for a while, which is not surprising because it only occurs in erroneous code in the first place.
Still, this makes debugging the original error of using an unbound variable much harder to find.
Here’s a slightly more practical example where this issue may arise:
foo(TestGoal) --> ( { TestGaol } -> bar ; baz ).
The typo in { TestGaol }
trigger the compile time error, where a singleton variable warning is due.