| author | |
| committer | |
| log | 007a260cda93004c93ef1c6f2e6155cb043188b6 |
| tree | a9f74e1cdf518b2b03f0eaaefd523253d5ce83aa |
| parent | 99adda9df5a5ae6c16b60da6ba7d57fd2154b81c |
| parent | ea3d9d5c536cb1cf5e015114f8b6e5bc96b8a805 |
| signature |
4 files changed, 22 insertions(+), 3 deletions(-)
src/analyze.cpp+1-1| ... | @@ -1634,7 +1634,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc | ... | @@ -1634,7 +1634,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1634 | } | 1634 | } |
| 1635 | } else if (param_node->data.param_decl.var_token != nullptr) { | 1635 | } else if (param_node->data.param_decl.var_token != nullptr) { |
| 1636 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 1636 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 1637 | add_node_error(g, param_node->data.param_decl.type, | 1637 | add_node_error(g, param_node, |
| 1638 | buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'", | 1638 | buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'", |
| 1639 | calling_convention_name(fn_type_id.cc))); | 1639 | calling_convention_name(fn_type_id.cc))); |
| 1640 | return g->builtin_types.entry_invalid; | 1640 | return g->builtin_types.entry_invalid; |
std/zig/parser_test.zig+9| ... | @@ -1,3 +1,12 @@ | ... | @@ -1,3 +1,12 @@ |
| 1 | test "zig fmt: infix operator and then multiline string literal" { | ||
| 2 | try testCanonical( | ||
| 3 | \\const x = "" ++ | ||
| 4 | \\ \\ hi | ||
| 5 | \\; | ||
| 6 | \\ | ||
| 7 | ); | ||
| 8 | } | ||
| 9 | |||
| 1 | test "zig fmt: C pointers" { | 10 | test "zig fmt: C pointers" { |
| 2 | try testCanonical( | 11 | try testCanonical( |
| 3 | \\const Ptr = [*c]i32; | 12 | \\const Ptr = [*c]i32; |
std/zig/render.zig+3-2| ... | @@ -340,7 +340,6 @@ fn renderExpression( | ... | @@ -340,7 +340,6 @@ fn renderExpression( |
| 340 | ast.Node.Id.InfixOp => { | 340 | ast.Node.Id.InfixOp => { |
| 341 | const infix_op_node = @fieldParentPtr(ast.Node.InfixOp, "base", base); | 341 | const infix_op_node = @fieldParentPtr(ast.Node.InfixOp, "base", base); |
| 342 | 342 | ||
| 343 | const op_token = tree.tokens.at(infix_op_node.op_token); | ||
| 344 | const op_space = switch (infix_op_node.op) { | 343 | const op_space = switch (infix_op_node.op) { |
| 345 | ast.Node.InfixOp.Op.Period, ast.Node.InfixOp.Op.ErrorUnion, ast.Node.InfixOp.Op.Range => Space.None, | 344 | ast.Node.InfixOp.Op.Period, ast.Node.InfixOp.Op.ErrorUnion, ast.Node.InfixOp.Op.Range => Space.None, |
| 346 | else => Space.Space, | 345 | else => Space.Space, |
| ... | @@ -353,7 +352,9 @@ fn renderExpression( | ... | @@ -353,7 +352,9 @@ fn renderExpression( |
| 353 | }; | 352 | }; |
| 354 | 353 | ||
| 355 | try renderToken(tree, stream, infix_op_node.op_token, indent, start_col, after_op_space); | 354 | try renderToken(tree, stream, infix_op_node.op_token, indent, start_col, after_op_space); |
| 356 | if (after_op_space == Space.Newline) { | 355 | if (after_op_space == Space.Newline and |
| 356 | tree.tokens.at(tree.nextToken(infix_op_node.op_token)).id != Token.Id.MultilineStringLiteralLine) | ||
| 357 | { | ||
| 357 | try stream.writeByteNTimes(' ', indent + indent_delta); | 358 | try stream.writeByteNTimes(' ', indent + indent_delta); |
| 358 | start_col.* = indent + indent_delta; | 359 | start_col.* = indent + indent_delta; |
| 359 | } | 360 | } |
test/compile_errors.zig+9| ... | @@ -1,6 +1,15 @@ | ... | @@ -1,6 +1,15 @@ |
| 1 | const tests = @import("tests.zig"); | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | ||
| 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.addTest( | ||
| 5 | "export generic function", | ||
| 6 | \\export fn foo(num: var) i32 { | ||
| 7 | \\ return 0; | ||
| 8 | \\} | ||
| 9 | , | ||
| 10 | ".tmp_source.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'ccc'", | ||
| 11 | ); | ||
| 12 | |||
| 4 | cases.addTest( | 13 | cases.addTest( |
| 5 | "C pointer to c_void", | 14 | "C pointer to c_void", |
| 6 | \\export fn a() void { | 15 | \\export fn a() void { |