@opencode/codemode 0.0.0-dev-19968 → 0.0.0-dev-19971
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.
|
@@ -1359,14 +1359,14 @@ class Frame {
|
|
|
1359
1359
|
if (depth > MAX_CALL_DEPTH)
|
|
1360
1360
|
throw rangeError("Maximum call stack size exceeded", node);
|
|
1361
1361
|
const invocation = new Frame(this.ctx, new ScopeStack([...fn.capturedScopes, new Map()]), depth);
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
for (const
|
|
1366
|
-
|
|
1367
|
-
paramScope.set(name, { mutable: true, value: undefined, initialized: false });
|
|
1368
|
-
}
|
|
1362
|
+
// Seed all parameters first so defaults cannot fall through to same-named outer bindings.
|
|
1363
|
+
const paramScope = invocation.scopes.current();
|
|
1364
|
+
for (const parameter of fn.parameters) {
|
|
1365
|
+
for (const name of collectPatternNames(parameter)) {
|
|
1366
|
+
paramScope.set(name, { mutable: true, value: undefined, initialized: false });
|
|
1369
1367
|
}
|
|
1368
|
+
}
|
|
1369
|
+
const bind = Effect.gen(function* () {
|
|
1370
1370
|
for (const [index, parameter] of fn.parameters.entries()) {
|
|
1371
1371
|
if (parameter.type === "RestElement") {
|
|
1372
1372
|
yield* invocation.declarePattern(parameter.argument, new Arr(self.ctx.builtins.Array, args.slice(index)), true, parameter, true);
|
|
@@ -1374,6 +1374,8 @@ class Frame {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
yield* invocation.declarePattern(parameter, args[index], true, parameter, true);
|
|
1376
1376
|
}
|
|
1377
|
+
});
|
|
1378
|
+
const body = Effect.gen(function* () {
|
|
1377
1379
|
if (fn.body.type === "BlockStatement") {
|
|
1378
1380
|
invocation.scopes.push();
|
|
1379
1381
|
invocation.hoistVars(fn.body.body, paramScope);
|
|
@@ -1382,8 +1384,10 @@ class Frame {
|
|
|
1382
1384
|
}
|
|
1383
1385
|
return yield* invocation.evaluateExpression(fn.body);
|
|
1384
1386
|
});
|
|
1387
|
+
// Generators bind parameters at the call and defer only the body to the first `next()`, as in JS.
|
|
1385
1388
|
if (fn.generator)
|
|
1386
|
-
return Effect.
|
|
1389
|
+
return Effect.map(bind, () => this.createGenerator(invocation, body, fn));
|
|
1390
|
+
const run = Effect.andThen(bind, body);
|
|
1387
1391
|
if (!fn.async)
|
|
1388
1392
|
return run;
|
|
1389
1393
|
return this.ctx.pending.createWithSelf((self) => Effect.flatMap(run, (value) => resolvePromiseValue(invocation.ctx, value, self)));
|
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-
|
|
4
|
+
"version": "0.0.0-dev-19971",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|