Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Read translated version (en)](./translations/en/CHANGELOG.md)

# 未リリース分
- 関数の省略された引数は`exists`でfalseを返すように

# 0.18.0
- `Core:abort`でプログラムを緊急停止できるように
Expand Down
2 changes: 1 addition & 1 deletion etc/aiscript.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type AddAssign_2 = NodeBase_2 & {
};

// @public (undocumented)
export const AISCRIPT_VERSION: "0.18.0";
export const AISCRIPT_VERSION: "0.19.0";

// @public (undocumented)
abstract class AiScriptError extends Error {
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ export class Interpreter {
return result ?? NULL;
} else {
const _args = new Map<string, Variable>();
for (let i = 0; i < (fn.args ?? []).length; i++) {
_args.set(fn.args![i]!, {
if (fn.args) for (let i = 0; i < fn.args.length; i++) {
if (args[i]) _args.set(fn.args[i]!, {
isMutable: true,
value: args[i]!,
});
Expand Down
21 changes: 21 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,27 @@ describe('Function call', () => {
}
assert.fail();
});

test.concurrent('exists on unprovided arg', async () => {
const res = await exe(`
@f(x) { return exists x }
<: f()
`);
eq(res, FALSE);
});

test.concurrent('accessing unprovided arg', async () => {
try {
await exe(`
@f(x) { return x }
<: f()
`);
} catch (e) {
assert.ok(e instanceof AiScriptRuntimeError);
return;
}
assert.fail();
});
});

describe('Return', () => {
Expand Down