Skip to content
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

DCG: instantiation_error if the name of a variable bound to a string is not in square brackets #2783

Closed
haijinSk opened this issue Jan 20, 2025 · 6 comments

Comments

@haijinSk
Copy link

A file to consult:

:- use_module(library(dcgs)).

test --> { String = "string" }, String.

A query:

?- phrase(test,S).
   error(instantiation_error,call/2), unexpected.
   S = "string". % expected, but not found.
@haijinSk haijinSk changed the title DCG: instantiation_error, if a variable bound to a string is not in square brackets DCG: instantiation_error if the name of a variable bound to a string is not in square brackets Jan 20, 2025
@UWN
Copy link

UWN commented Jan 20, 2025

Shorter:

?- phrase(({S="a"},phrase(S)),L).
   error(instantiation_error,call/2), unexpected.
   S = "a".
?- phrase(({S="a"},S),L).
   idem.
?- S="a",phrase(({S="a"},S),L).
   idem. % even here!!

@UWN
Copy link

UWN commented Jan 20, 2025

?- S="a",phrase(S,L).
   idem.

@triska
Copy link
Contributor

triska commented Jan 20, 2025

Is this addressed by #2738?

@haijinSk
Copy link
Author

haijinSk commented Jan 20, 2025

Now I see here:

#2725 (comment)

example by @adri326

So I'm closing this...

@UWN
Copy link

UWN commented Jan 21, 2025

Let me again thank you for reporting the error in the very form you did. I added it as phrase#40 in an even more simplified version. And, as it turns out there are problems with a total of four systems. Identifying such "tiny" problems is one way we can improve the language we love.

@haijinSk
Copy link
Author

@UWN Thank you very much. The form of reporting, indicating the unexpected and adding what was expected directly to code examples, I learned it from you.

Yes, when I'm not sure how many and which examples I should include to be informative in the right way, my reporting tends to be more ad hoc, improvisational, trying to be evocative at least.

Not an ideal Prolog user, but I'm "here", slowly here, so to speak; very slowly, nevertheless, to explore, to try, to learn, to be inspired, yes, to love the language and this implementation, incarnation of ideas/perspectives.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants