mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.
BSD 3-Clause "New" or "Revised" License
2.05k stars 120 forks source link

Create procedure defect #2529

Open flexoron opened 2 months ago

flexoron commented 2 months ago
?- [user].
'P'.

   error(permission_error(create,static_procedure,nameless_procedure),load/1). % unexpected
?- 
triska commented 2 months ago

Excellent catch!

Also:

?- assertz('A').
   error(type_error(callable,'A'),assertz/1), unexpected.
   true. % expected
bakaq commented 2 months ago

Possibly related to #2496, but uppercase characters are much more common.

UWN commented 2 months ago

'A'/0 can be asserted like so:


?- atom_chars(A,"A"), asserta(A).
   A = 'A'.
?- 'A'.
   true.
?- asserta('A').
   error(type_error(callable,'A'),asserta/1), unexpected.  % but not in this manner
bakaq commented 2 months ago

Seems to be an issue with parsing/compiling then.

flexoron commented 2 months ago
$ scryer-prolog -f
?- [user].
'A'('A').

?- 'A'(A).
   A = 'A'.
?- atom_chars(A,"A"), 'A'(A), asserta(A).
   A = 'A'.
%
% Addition: 'A'/0 can't be asserted like so:
%
?- 'A'(A), atom_chars(A,"A"), asserta(A).
   error(type_error(callable,'A'),asserta/1).
hurufu commented 2 months ago

I think it is related to string handling:

?- [user].
'P'.

   error(permission_error(create,static_procedure,nameless_procedure),load/1).
?- 'P'.
   error(existence_error(procedure,'P'/0),'P'/0).
?- [user].
'PP'.

?- 'PP'.
   true.
?- 

It happens only for single letter predicates.

UWN commented 2 months ago

It depends on the exact way how that name has been created

?- char_code(A,0'A),asserta(A).
   error(type_error(callable,'A'),asserta/1), unexpected.
?- char_code(A,0'a),asserta(A).
   error(type_error(callable,a),asserta/1), unexpected.
?- asserta('a').
   error(type_error(callable,a),asserta/1), unexpected.
?- asserta(a).
   true. % expected
triska commented 1 month ago

Good news everyone: These cases work with the rebis-dev development branch!