@opencode/codemode 0.0.0-dev-20032 → 0.0.0-dev-20035

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.
@@ -717,10 +717,10 @@ class Frame {
717
717
  self.predeclarePattern(declared.pattern, declared.mutable, left);
718
718
  const right = yield* self.evaluateExpression(node.right);
719
719
  const keys = self.enumerableKeys(right, node.right);
720
- if (left.type !== "Identifier" && left.type !== "VariableDeclaration") {
720
+ if (left.type === "RestElement" || left.type === "AssignmentPattern") {
721
721
  throw typeError("Unsupported for...in binding.", left);
722
722
  }
723
- const assignmentName = left.type === "Identifier" ? left.name : undefined;
723
+ const assignment = left.type === "VariableDeclaration" ? undefined : left;
724
724
  for (const key of keys) {
725
725
  const result = yield* Effect.gen(function* () {
726
726
  if (declared?.lexical) {
@@ -731,8 +731,8 @@ class Frame {
731
731
  else if (declared) {
732
732
  yield* self.assignPattern(declared.pattern, key, left);
733
733
  }
734
- else if (assignmentName) {
735
- self.scopes.set(assignmentName, key, left);
734
+ else if (assignment) {
735
+ yield* self.assignPattern(assignment, key, left);
736
736
  }
737
737
  return yield* self.evaluateStatement(node.body);
738
738
  }).pipe(Effect.ensuring(Effect.sync(() => {
@@ -1370,12 +1370,16 @@ class Frame {
1370
1370
  paramScope.set(name, { mutable: true, value: undefined, initialized: false });
1371
1371
  }
1372
1372
  }
1373
+ const parameters = fn.parameters.map((parameter) => parameter.type === "Identifier" ? parameter.name : undefined);
1373
1374
  const bind = Effect.gen(function* () {
1374
1375
  for (const [index, parameter] of fn.parameters.entries()) {
1375
1376
  if (parameter.type === "RestElement") {
1376
1377
  yield* invocation.declarePattern(parameter.argument, new Arr(self.ctx.builtins.Array, args.slice(index)), true, parameter, true);
1377
1378
  break;
1378
1379
  }
1380
+ // A sloppy simple parameter list may repeat a name; the last occurrence wins, as in JS.
1381
+ if (parameter.type === "Identifier" && parameters.lastIndexOf(parameter.name) !== index)
1382
+ continue;
1379
1383
  yield* invocation.declarePattern(parameter, args[index], true, parameter, true);
1380
1384
  }
1381
1385
  });
@@ -15,20 +15,16 @@ const flagProperties = [
15
15
  const regexFailureReason = (error) => (error instanceof Error ? error.message : String(error)).replace(/^Invalid regular expression:\s*/i, "");
16
16
  const escapeRegexHint = 'To match special characters like ( ) [ ] { } + * ? . literally, escape them with a backslash (e.g. "\\\\(") or test for them with String.includes instead.';
17
17
  export const toHostRegex = (arg, method, extraFlags = "") => {
18
- // Native parity: an undefined pattern behaves as an empty pattern.
19
- if (arg === undefined)
20
- return new RegExp("", extraFlags);
21
18
  if (arg instanceof RegExpObj)
22
19
  return arg.regex;
23
- if (typeof arg === "string") {
24
- try {
25
- return new RegExp(arg, extraFlags);
26
- }
27
- catch (error) {
28
- throw syntaxError(`String.${method} received the string ${JSON.stringify(arg)}, which is not a valid regular expression pattern (${regexFailureReason(error)}). ${escapeRegexHint}`);
29
- }
20
+ // Anything else is a pattern string, as `new RegExp(arg)` would read it: undefined is the empty pattern.
21
+ const source = arg === undefined ? "" : coerceToString(arg);
22
+ try {
23
+ return new RegExp(source, extraFlags);
24
+ }
25
+ catch (error) {
26
+ throw syntaxError(`String.${method} received the string ${JSON.stringify(source)}, which is not a valid regular expression pattern (${regexFailureReason(error)}). ${escapeRegexHint}`);
30
27
  }
31
- throw typeError(`String.${method} expects a regular expression (a /pattern/flags literal or new RegExp(...)) or a string pattern, not ${arg === null ? "null" : typeof arg}.`);
32
28
  };
33
29
  export const matchToValue = (builtins, match) => {
34
30
  const result = new Arr(builtins.Array, Array.from(match, (group) => group));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/codemode",
4
- "version": "0.0.0-dev-20032",
4
+ "version": "0.0.0-dev-20035",
5
5
  "description": "Effect-native confined code execution over schema-described tools",
6
6
  "type": "module",
7
7
  "license": "MIT",