-
Notifications
You must be signed in to change notification settings - Fork 159
populate the second argument of error terms thrown from rust with a context list #3173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as soon as it works: [predicate-call/0]? (that's the expectation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source of this error appears to be
scryer-prolog/src/machine/machine_state.rs
Lines 575 to 580 in e4d9692
| pub(super) fn throw_undefined_error(&mut self, name: Atom, arity: usize) -> MachineStub { | |
| let stub = functor_stub(name, arity); | |
| let err = self.existence_error(ExistenceError::Procedure(name, arity)); | |
| self.error_form(err, stub) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.