eyeprolog 1.5.76 → 1.5.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.5.76",
6
+ "version": "1.5.77",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/src/iso.js CHANGED
@@ -1162,6 +1162,12 @@ function streamHandleId(value, env) {
1162
1162
  // and rejecting an equally valid stream reference as malformed.
1163
1163
  if (value.type !== COMPOUND || value.name !== '$stream' || value.arity !== 1) return null;
1164
1164
  const id = deref(value.args[0], env);
1165
+ // The shape is right, but the argument that would identify the stream is
1166
+ // still unbound: whether this term is a valid stream reference cannot be
1167
+ // decided yet, so that is an instantiation error, not a domain error (see
1168
+ // issue #109's stc#72 follow-up) — unlike a wrong functor/arity above,
1169
+ // which can never become valid no matter how any variable gets bound.
1170
+ if (id.type === VAR) throw new PrologError('instantiation_error');
1165
1171
  return id.type === NUMBER && isDecimalInteger(id.name) ? Number(id.name) : null;
1166
1172
  }
1167
1173
 
@@ -46,6 +46,21 @@ export function regressionCases() {
46
46
  assertIncludes(result.stdout, 'A1 = ', 'query succeeds and reports the shared stream number');
47
47
  },
48
48
  },
49
+ {
50
+ name: 'close/1 raises instantiation_error, not domain_error(stream_or_alias), for a $stream/1 term whose argument is unbound (issue #109 follow-up)',
51
+ run: () => {
52
+ const result = runCli([], { input:
53
+ "S='$stream'(X),close(S).\nhalt.\n",
54
+ });
55
+ assertEqual(result.status, 0, result.stderr);
56
+ // The argument that would identify the stream is still unbound, so
57
+ // whether this term is a valid stream reference cannot be decided
58
+ // yet — that calls for instantiation_error, not a domain_error
59
+ // claiming the term itself is already known to be invalid.
60
+ assertIncludes(result.stdout, 'error(instantiation_error,', 'unbound $stream/1 argument reports instantiation_error');
61
+ assertNotIncludes(result.stdout, 'domain_error(stream_or_alias', 'no domain_error(stream_or_alias, ...) once the argument is still unbound');
62
+ },
63
+ },
49
64
  {
50
65
  name: 'top level never mints a generated variable name that collides with a query variable\'s own name (issue #108)',
51
66
  run: () => {