Skip to content

Commit

Permalink
Merge pull request #373 from guregu/lax-clause
Browse files Browse the repository at this point in the history
Support clause/2,3 for non-dynamic clauses
  • Loading branch information
infradig authored Oct 18, 2023
2 parents 2deba0c + a68b793 commit 8352158
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,11 @@ static bool directives(parser *p, cell *d)
p->m->flags.occurs_check = true;
else if (!strcmp(C_STR(p, p2), "false") || !strcmp(C_STR(p, p2), "off"))
p->m->flags.occurs_check = false;
} else if (!strcmp(C_STR(p, p1), "strict_iso")) {
if (!strcmp(C_STR(p, p2), "true") || !strcmp(C_STR(p, p2), "on"))
p->m->flags.not_strict_iso = false;
else if (!strcmp(C_STR(p, p2), "false") || !strcmp(C_STR(p, p2), "off"))
p->m->flags.not_strict_iso = true;
} else {
//fprintf(stdout, "Warning: unknown flag: %s\n", C_STR(p, p1));
}
Expand Down
7 changes: 4 additions & 3 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,9 +1282,10 @@ bool match_clause(query *q, cell *p1, pl_idx p1_ctx, enum clause_type is_retract
}

if (!pr->is_dynamic) {
if (is_retract == DO_CLAUSE)
return throw_error(q, p1, p1_ctx, "permission_error", "access,private_procedure");
else
if (is_retract == DO_CLAUSE) {
if (!q->flags.not_strict_iso)
return throw_error(q, p1, p1_ctx, "permission_error", "access,private_procedure");
} else
return throw_error(q, p1, p1_ctx, "permission_error", "modify,static_procedure");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/issues/test372.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
answer(41):-1=:=2,fail
answer(42):-true
8 changes: 8 additions & 0 deletions tests/issues/test372.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:-initialization(main).
:-set_prolog_flag(strict_iso,off).

answer(41) :- 1 =:= 2, fail.
answer(42).

main :- H = answer(X), clause(H, Body), writeln((H :- Body)), fail.
main.

0 comments on commit 8352158

Please sign in to comment.