authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-08 19:28:01+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-09 20:37:18-07:00
log5831b68341827b544ea3f268c921e9044bd11047
tree552359dd5f312f582e45ba84d2e656c85cd7e697
parentb483c796c66e3a415a7590bfe62f316fa8fa70e6

AstGen: add check for missing builtin argument

Closes #13817

2 files changed, 17 insertions(+), 0 deletions(-)

src/AstGen.zig+4
...@@ -9098,6 +9098,8 @@ fn nodeMayNeedMemoryLocation(tree: *const Ast, start_node: Ast.Node.Index, have_...@@ -9098,6 +9098,8 @@ fn nodeMayNeedMemoryLocation(tree: *const Ast, start_node: Ast.Node.Index, have_
9098 .always => return true,9098 .always => return true,
9099 .forward1 => node = node_datas[node].rhs,9099 .forward1 => node = node_datas[node].rhs,
9100 }9100 }
9101 // Missing builtin arg is not a parsing error, expect an error later.
9102 if (node == 0) return false;
9101 },9103 },
91029104
9103 .builtin_call, .builtin_call_comma => {9105 .builtin_call, .builtin_call_comma => {
...@@ -9112,6 +9114,8 @@ fn nodeMayNeedMemoryLocation(tree: *const Ast, start_node: Ast.Node.Index, have_...@@ -9112,6 +9114,8 @@ fn nodeMayNeedMemoryLocation(tree: *const Ast, start_node: Ast.Node.Index, have_
9112 .always => return true,9114 .always => return true,
9113 .forward1 => node = params[1],9115 .forward1 => node = params[1],
9114 }9116 }
9117 // Missing builtin arg is not a parsing error, expect an error later.
9118 if (node == 0) return false;
9115 },9119 },
9116 }9120 }
9117 }9121 }
test/cases/compile_errors/missing_builtin_arg_in_initializer.zig created+13
...@@ -0,0 +1,13 @@
1comptime {
2 const v = @as();
3}
4comptime {
5 const u = @bitCast(u32);
6}
7
8// error
9// backend=stage2
10// target=native
11//
12// :2:15: error: expected 2 arguments, found 0
13// :5:15: error: expected 2 arguments, found 1