Merge branch 'kristate-zig-backport-issue1944'
This commit is contained in:
commit
007a260cda
|
@ -1634,7 +1634,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
|
||||||
}
|
}
|
||||||
} else if (param_node->data.param_decl.var_token != nullptr) {
|
} else if (param_node->data.param_decl.var_token != nullptr) {
|
||||||
if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
|
if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
|
||||||
add_node_error(g, param_node->data.param_decl.type,
|
add_node_error(g, param_node,
|
||||||
buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'",
|
buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'",
|
||||||
calling_convention_name(fn_type_id.cc)));
|
calling_convention_name(fn_type_id.cc)));
|
||||||
return g->builtin_types.entry_invalid;
|
return g->builtin_types.entry_invalid;
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
test "zig fmt: infix operator and then multiline string literal" {
|
||||||
|
try testCanonical(
|
||||||
|
\\const x = "" ++
|
||||||
|
\\ \\ hi
|
||||||
|
\\;
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "zig fmt: C pointers" {
|
test "zig fmt: C pointers" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\const Ptr = [*c]i32;
|
\\const Ptr = [*c]i32;
|
||||||
|
|
|
@ -340,7 +340,6 @@ fn renderExpression(
|
||||||
ast.Node.Id.InfixOp => {
|
ast.Node.Id.InfixOp => {
|
||||||
const infix_op_node = @fieldParentPtr(ast.Node.InfixOp, "base", base);
|
const infix_op_node = @fieldParentPtr(ast.Node.InfixOp, "base", base);
|
||||||
|
|
||||||
const op_token = tree.tokens.at(infix_op_node.op_token);
|
|
||||||
const op_space = switch (infix_op_node.op) {
|
const op_space = switch (infix_op_node.op) {
|
||||||
ast.Node.InfixOp.Op.Period, ast.Node.InfixOp.Op.ErrorUnion, ast.Node.InfixOp.Op.Range => Space.None,
|
ast.Node.InfixOp.Op.Period, ast.Node.InfixOp.Op.ErrorUnion, ast.Node.InfixOp.Op.Range => Space.None,
|
||||||
else => Space.Space,
|
else => Space.Space,
|
||||||
|
@ -353,7 +352,9 @@ fn renderExpression(
|
||||||
};
|
};
|
||||||
|
|
||||||
try renderToken(tree, stream, infix_op_node.op_token, indent, start_col, after_op_space);
|
try renderToken(tree, stream, infix_op_node.op_token, indent, start_col, after_op_space);
|
||||||
if (after_op_space == Space.Newline) {
|
if (after_op_space == Space.Newline and
|
||||||
|
tree.tokens.at(tree.nextToken(infix_op_node.op_token)).id != Token.Id.MultilineStringLiteralLine)
|
||||||
|
{
|
||||||
try stream.writeByteNTimes(' ', indent + indent_delta);
|
try stream.writeByteNTimes(' ', indent + indent_delta);
|
||||||
start_col.* = indent + indent_delta;
|
start_col.* = indent + indent_delta;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
const tests = @import("tests.zig");
|
const tests = @import("tests.zig");
|
||||||
|
|
||||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||||
|
cases.addTest(
|
||||||
|
"export generic function",
|
||||||
|
\\export fn foo(num: var) i32 {
|
||||||
|
\\ return 0;
|
||||||
|
\\}
|
||||||
|
,
|
||||||
|
".tmp_source.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'ccc'",
|
||||||
|
);
|
||||||
|
|
||||||
cases.addTest(
|
cases.addTest(
|
||||||
"C pointer to c_void",
|
"C pointer to c_void",
|
||||||
\\export fn a() void {
|
\\export fn a() void {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user