Skip to content

Commit 5863a37

Browse files
authored
Merge pull request #403 from Daaisukidayo/patch-1
fix ForgeFunction argument handling and firstParamCondition
2 parents f9d48e7 + a5e0848 commit 5863a37

4 files changed

Lines changed: 20 additions & 16 deletions

File tree

dist/structures/forge/ForgeFunction.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/structures/forge/ForgeFunction.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/structures/forge/ForgeFunction.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/structures/forge/ForgeFunction.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class ForgeFunction {
6767
const params = await this["resolveMultipleArgs"](ctx, ...this.data.fields.slice(1).map((_, i) => i + 1))
6868
if (!this["isValidReturnType"](params.return))
6969
return params.return
70-
return outer.call(ctx, this, params.args)
70+
return outer.call(ctx, this, [condition.value as string, ...params.args])
7171
} else {
7272
return outer.call(ctx, this, args ?? [])
7373
}
@@ -91,17 +91,20 @@ export class ForgeFunction {
9191
)
9292
)
9393

94+
const functionCtx = ctx.clone({
95+
doNotSend: true,
96+
allowTopLevelReturn: true,
97+
data: this.compiled
98+
})
99+
94100
for (let i = 0, len = params.length; i < len; i++) {
95101
const param = params[i]
96102
const name = typeof param === "string" ? param : param.name
97-
ctx.setEnvironmentKey(name, args[i])
103+
104+
functionCtx.setEnvironmentKey(name, args[i])
98105
}
99106

100-
const result = await Interpreter.run(ctx.clone({
101-
doNotSend: true,
102-
allowTopLevelReturn: true,
103-
data: this.compiled
104-
}))
107+
const result = await Interpreter.run(functionCtx)
105108

106109
return result === null ? fn.stop() : fn.success(result)
107110
}

0 commit comments

Comments
 (0)