trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
268 stars 13 forks source link

predicate_property/2 bug #599

Closed pmoura closed 21 hours ago

pmoura commented 1 day ago

Noticed that one of the Logtalk self_vs_super example tests is failing. This failure exposes a bug in the Trealla Prolog implementation of the predicate_property/2 built-in predicate:

$ tplgt -q
?- {self_vs_super(loader)}.
% [ /Users/pmoura/logtalk/examples/self_vs_super/self_vs_super.lgt loaded ]
% [ /Users/pmoura/logtalk/examples/self_vs_super/loader.lgt loaded ]
% (0 warnings)
   true.
?- predicate_property(foo(_), P).
   P = static
;  P = interpreted.
?- predicate_property(foo(_), built_in).
   true.

The foo/1 predicate is defined in user. Enumerating all its properties doesn't (correctly) list the built_in property. But explicitly checking for this property unexpectedly succeeds.

pmoura commented 1 day ago

Pushed additional tests for the predicate_property/2 predicate:

$ logtalk_tester -p trealla
% Batch testing started @ 2024-09-30 10:50:27
%         Logtalk version: 3.84.0-b01
%         Trealla Prolog version: 2.56.22
%
% Documents/Logtalk/logtalk3/tests/prolog/predicates/predicate_property_2
%         29 tests: 0 skipped, 27 passed, 2 failed (0 flaky)
%         completed tests from object tests in 2 seconds
%         clause coverage n/a
%
% Compilation errors/warnings and failed unit tests
% (compilation errors/warnings might be expected depending on the test)
!     commons_predicate_property_2_09: failure (in 0.000006000/0.000000000 cpu/wall seconds)
!       test goal succeeded but should have failed
!       in file Documents/Logtalk/logtalk3/tests/prolog/predicates/predicate_property_2/tests.lgt between lines 77-78
!     
!     commons_predicate_property_2_12: failure (in 0.000004000/0.000000000 cpu/wall seconds)
!       test goal succeeded but should have failed
!       in file Documents/Logtalk/logtalk3/tests/prolog/predicates/predicate_property_2/tests.lgt between lines 86-87
!     
%
% Failed tests
Documents/Logtalk/logtalk3/tests/prolog/predicates/predicate_property_2/tests.lgt - commons_predicate_property_2_09 @ tests
Documents/Logtalk/logtalk3/tests/prolog/predicates/predicate_property_2/tests.lgt - commons_predicate_property_2_12 @ tests
%
% 1 test sets: 1 completed, 0 skipped, 0 broken, 0 timedout, 0 crashed
% 29 tests: 0 skipped, 27 passed, 2 failed (0 flaky)
%
% Batch testing ended @ 2024-09-30 10:50:30
infradig commented 1 day ago

What properties does Logtalk rely on? I would like to reduce the number as SWI which I initially tried to model has too many, some redundant.

I would think just ones that correspond to actual properties... like dynamic, exported, discontiguous, meta_predicate, multifile & perhaps some state ones template, line_nbr, built_in and iso.

infradig commented 1 day ago

Actually, ignore that question.

pmoura commented 1 day ago

A minimal set of properties would be built_in, static, dynamic, foreign (assuming FLI support), multifile, meta_predicate plus the properties that are a consequence of providing a module system (e.g. imported_from). Btw, most of these properties are specified in the ISO/IEC 13211-2 standard (not that the specification of the predicate_property/2 belongs there).

pmoura commented 21 hours ago

Thanks for the quick fix.