run --goal silently truncates a query at the first unparsed token (wrong-but-successful results) #30
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-prolog#30
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
prlg run --goal "<query>"parses a single term and silently discards anytrailing tokens. When the query contains an operator the parser doesn't know,
everything from that point on is dropped — and the truncated query can succeed
with a wrong binding.
Repro
8 >> 1is4, andX =:= 4should fail forX = 8— but the query istruncated at the unknown
>>to justX is 8, which succeeds withX = 8.The trailing conjuncts (
>> 1, X =:= 4) are silently dropped.Another form — trailing garbage is ignored entirely:
Contrast: in-file clauses are correct
Clause bodies require a terminating
., so the same construct correctly errorsrather than truncating:
So the bug is specific to the query path (
parse_queryincrates/patch-prolog-core/src/parser.rs), which doesn't enforce that the wholeinput is consumed.
Impact
A multi-goal
--goalquery can return a wrong-but-successful result, maskingboth unknown-operator errors and real query failures. (loglings itself is not
exposed — it only ever passes the single-atom goals
test/true.)Suggested fix
After parsing the query term(s), require EOF; if tokens remain, raise a parse
error (the same contract the clause reader already enforces with its trailing
.).Reported against
prlg0.4.1. Found while building theloglingsexercises.#34