populate the second argument of error terms thrown from rust with a context list#3173
populate the second argument of error terms thrown from rust with a context list#3173Skgland wants to merge 9 commits intomthom:masterfrom
Conversation
MachineError now makes the second argument of the error/2 term a list of contexts . The location information for syntax errors is now passed as part of this context.
|
The (.)/2 list terms are being constructed at scryer-prolog/src/machine/machine_errors.rs Lines 732 to 745 in 4bd8342 |
tests/scryer/issues.rs
Outdated
| load_module_test( | ||
| "tests-pl/issue831-call0.pl", | ||
| " error(existence_error(procedure,call/0),call/0).\n", | ||
| " error(existence_error(procedure,call/0),'.'(predicate-call/0,[])).\n", |
There was a problem hiding this comment.
as soon as it works: [predicate-call/0]? (that's the expectation)
There was a problem hiding this comment.
Based on the old error that would be my expectation.
Though the error context appears to be rather odd even for the old error.
With the second argument usually being the predicate that encountered an error this would mean that call/0 failed to find call/0 which shouldn't happen as call/0 doesn't exists.
Wherever that error is being thrown the context appears to be off.
There was a problem hiding this comment.
The source of this error appears to be
scryer-prolog/src/machine/machine_state.rs
Lines 575 to 580 in e4d9692
There was a problem hiding this comment.
In ab34905 I have now removed the predicate context for those errors.
I don't see any useful context being available.
Though it might be worth looking into adding context for goals evaluated as part of an initialization/1 directive i.e. something like [declaration-initialization/1, goal-Goal, file-File, line-Line]
so that MachineErrors without predicate-_ context can be created
Make errors thrown from rust compatible with call_with_error_context/2 in that the second argument of a thrown error is a list.
This exasperates the problem described in #3171 as now way more list terms are constructed from rust (see updated tests) and as such this PR is blocked on that issue being resolved.