Commit Graph

3110 Commits

Author SHA1 Message Date
Emilie Burgun
949d316773 Fix realiased streams causing close/1 to leave a dangling stream 2025-02-06 23:00:00 +01:00
Emilie Burgun
0cf46d3ec4 Encapsulate accesses to IndexStore::streams and ::stream_aliases
These two fields are able to hold `Stream` instances, which predicates like `close/1`
expect to be managed properly for their correctness. To ensure that this is the case,
I have removed direct accesses to those two fields, so that they can be properly managed
in one place.
2025-02-06 23:00:00 +01:00
Emilie Burgun
2fe7b55343 Fix close/1 messing up stream_aliases when user_input or user_output aren't set to Stdin and Stdout 2025-02-03 00:07:39 +01:00
bakaq
590d0daa24 Fix clippy warnings 2025-01-28 16:49:41 -03:00
Mark Thom
5a869e8b48 Merge pull request #2777 from adri326/fix-2772-rnd_i-clipping
Fix invalid casts in is/2
2025-01-26 23:14:57 -07:00
Emilie Burgun
0cde8f9a43 Add integration tests for arithmetic operators
This extensively tests the behavior of is/2, both when compiled and in metacalls.
2025-01-27 00:10:56 +01:00
Emilie Burgun
20735ea34c Fix integer overflow in >>/2 and <</2 2025-01-27 00:10:47 +01:00
Emilie Burgun
f3a92c6551 Fix min/2 and max/2 returning the cast version of its arguments
It now behaves the same way as SWI-Prolog.
2025-01-27 00:06:06 +01:00
Emilie Burgun
e2d1a2b6bc Fix X is gcd(1, 2 ^ 64) triggering a panic
The implementation for gcd/2 would cast the second argument to an isize.
2025-01-27 00:06:06 +01:00
Emilie Burgun
d3361c16d8 Fix round() losing precision on bigints
The original issue can be reproduced with `X is round(2 ^ 54 + 1) - 2 ^ 54, X = 1.`
2025-01-27 00:05:30 +01:00
Emilie Burgun
9420c7e41e Fix rnd_i clipping floats that don't fit in Fixnum
Fixes #2772.

The current implementation of `rnd_i` incorrectly casts `f` (an `f64`)
into an `i64`, before casting it into an `Integer`.

This fixes that issue by using `Integer::try_from(f)` instead,
and failing if `f` is infinite or NaN.

A fixme is left for a future PR to properly handle the resulting errors
in floor/1 and friends (right now they can only be triggered through FFI).
2025-01-27 00:02:04 +01:00
Emilie Burgun
b76bdd75e4 Fix #2725 by calling load_context/1 in the unspecified branch of strip_module/3
This fixes #2725, by making it so that `strip_module(Pred, M, P), call(M:P)`
doesn't throw an `instanciation_error` when `Pred` isn't in the form `module:predicate`.

Now, `strip_module(hello, M, P)` will call `load_context(M)`, which unifies `M`
with the topmost module (or `user`).

Two new test cases are added: issue2725.pl, which tests the minimal case id(X) --> X.
and the strip_module(P, M, _), call(M:P) scenario, and module_resolution,
which tests the behavior of strip_module in a few scenarios.
2025-01-12 14:08:28 +01:00
Emilie Burgun
6cedbc33c0 Fix load_context_module triggering unreachable code in unify_atom 2025-01-08 17:57:40 +01:00
Mark Thom
2856cc4371 Merge pull request #2742 from triska/clpb
Revert "FIXED: CLP(B): Delay BDD restriction until after the instantiation"
2025-01-04 13:26:08 -07:00
Mark Thom
2257503951 Merge pull request #2743 from triska/crypto
atom --> string
2025-01-04 13:23:59 -07:00
Markus Triska
28c386422b state when the predicates are true
"returns" is not used in this way in logic programming. "return"
suggests that something went away and is now coming back, but this is
never the case in these situations. The arguments may be variables or
also fully known at the time of the call in most cases.
2025-01-02 18:54:27 +01:00
Markus Triska
edaba024b2 atom --> string 2025-01-02 18:30:29 +01:00
Markus Triska
333d6740ae Revert "FIXED: CLP(B): Delay BDD restriction until after the instantiation."
This reverts commit e185b626bd.

This change is now no longer needed, and the underlying issue is
apparently somewhere else entirely. See the description at:

    https://github.com/mthom/scryer-prolog/issues/2732

Current master behaves differently from Scryer as it was at
099d9aaca6 (i.e., preceding
the commit that is now being reverted), even on the same file.

For an example, see:

    dd41176b97

Scryer now works as expected, and compatibly with SICStus. We still
need to find out what fixed the root cause of this issue.
2025-01-02 18:02:38 +01:00
Mark Thom
d57f871a12 Merge pull request #2681 from hurufu/remove-dcgs-that-have-failed-to-expand
Remove DCGs that have thrown an exception during term expansion
2024-12-25 14:29:38 -07:00
Mark Thom
afc7b74bbd qualify module quantification errors better (#2685) 2024-12-25 12:25:01 -08:00
Mark Thom
d287095e61 style corrections 2024-12-25 12:25:01 -08:00
Aleksy Grabowski
a599a11169 Remove DCGs that have thrown an exception during term expansion
Some DCG constructs aren't supported and can't be expanded, here we
remove offending DCG rule and don't compile it at all – in a similar
fashion to what we do when incorrect goal was found – whole predicate
isn't getting compiled.

Fixes #2675
2024-12-22 10:37:32 +01:00
Mark Thom
b7943837a0 Merge pull request #2714 from triska/graphic_token
prevent accidental amalgamation of graphic token chars in output
2024-12-20 18:42:09 -07:00
Mark Thom
e01a4cdc85 Merge pull request #2717 from jasagredo/js/small-doc
Ensure max_assoc/3 is shown as documented
2024-12-20 18:41:51 -07:00
Mark Thom
555dff5bad leave variable modules uninstantiated (#2685) 2024-12-19 20:20:29 -08:00
Javier Sagredo
75ac3fffae Ensure max_assoc/3 is shown as documented 2024-12-18 01:02:45 +01:00
Markus Triska
8dc80b815f use round brackets for goals involving operators
Examples:

    ?- portray_clause(((+) :- a=b,(-))).
    (+) :-
       a=b,
       (-).
       true.

    ?- portray_clause((a :- (b :- c))).
    a :-
       (b:-c).
       true.

This addresses #2715.

Currently, more round brackets than needed are emitted. Ideally, a
better approach to solve the issue here and also in toplevel.pl is
found in the future.
2024-12-17 22:51:47 +01:00
Markus Triska
6175e334a5 prevent accidental amalgamation of graphic token chars in output
This addresses #2713. Many thanks to @notoria for reporting this
excellent case!

Example:

    ?- portray_clause(A = @).
    A= @ .
       true.

At other positions the now inserted space is unnecessary, as in:

    ?- portray_clause((head:- @,b)).
    head :-
       @ ,
       b.
       true.

The toplevel has a similar issue:

    ?- C = # ; false.
       C = # |<-- cursor is here; redundant space after #

There may be a way to solve this issue for all cases like this.
2024-12-17 20:06:52 +01:00
Mark Thom
7e22c12a8d Merge pull request #2582 from bakaq/rework_library_interface
Rework library interface
2024-12-13 21:46:43 -07:00
Mark Thom
c59f54252c Merge pull request #2683 from ffortier/master
Support hermetic build environment
2024-12-13 21:39:12 -07:00
Mark Thom
a9a77779e3 Merge pull request #2689 from triska/weighted_maybe
introduce and use weighted_maybe/2
2024-12-13 21:38:47 -07:00
Mark Thom
5f035ec6ad Merge pull request #2690 from notoria/next
Add '$random_integer'/3
2024-12-13 21:38:32 -07:00
Mark Thom
9eef380764 Merge pull request #2696 from jasonhemann/patch-3
s/performance characters/performance characteristics/
2024-12-13 21:37:56 -07:00
Mark Thom
ce6a0a1541 Merge pull request #2698 from jasonhemann/patch-5
Documentation for read/2
2024-12-13 20:02:50 -07:00
Mark Thom
b919a39b96 Merge pull request #2703 from jasonhemann/patch-6
s/avaibale/available/
2024-12-13 20:02:21 -07:00
Jason Hemann
a15b2789e2 s/avaibale/available/
Quick typo fix to docs.
2024-12-13 13:41:05 -05:00
bakaq
2e910de485 cargo fmt 2024-12-12 06:03:43 -03:00
bakaq
74e3d32ca9 Use Cow<'a,B> for toplevel configuration 2024-12-12 05:59:59 -03:00
bakaq
500a6cdaf1 FIXME in Drop for QueryState 2024-12-12 05:49:52 -03:00
bakaq
17293a5753 Leave residual goals for later 2024-12-12 05:47:01 -03:00
bakaq
a75266c3ce Derive Default for StreamConfig 2024-12-12 05:47:01 -03:00
bakaq
a92eac919f Rename lib_machine_tests.rs to tests.rs 2024-12-12 05:46:54 -03:00
Jason Hemann
2ff50f06bc Update builtins.pl
s/compund/compound/
2024-12-11 08:05:03 -05:00
Jason Hemann
e219e1c483 Update builtins.pl
Simplifying docstring.
2024-12-11 05:46:28 -05:00
Jason Hemann
eef9f74a68 Documentation for read/2
Mirrored the wording in the docstrings for `read/1` and `read_term/3`.
2024-12-10 21:18:09 -05:00
Jason Hemann
eae1f53846 "bound to an atom"
Quick typo.
2024-12-10 21:07:48 -05:00
Jason Hemann
48a42ae140 s/performance characters/performance characteristics/
Small typo fix in docs.
2024-12-10 20:56:44 -05:00
bakaq
9265d66f58 Handle errors in QueryState 2024-12-08 20:18:06 -03:00
bakaq
3d3baeed82 Migrate benches 2024-12-08 20:18:06 -03:00
bakaq
e21c772181 Migrate tests to new API 2024-12-08 20:18:06 -03:00