| author | |
| committer | |
| log | 449554a7307731047fcd9c132386fdf405c3b237 |
| tree | c579c496ed162736b24930a17070c2544d4fc033 |
| parent | f4a249325e8e3741a6294462ae37a79cb9089c56 |
closes #1070511 files changed, 12 insertions(+), 78 deletions(-)
lib/std/crypto/benchmark.zig+2-2| ... | ... | @@ -297,8 +297,8 @@ pub fn benchmarkAes8(comptime Aes: anytype, comptime count: comptime_int) !u64 { |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | const CryptoPwhash = struct { |
| 300 | hashFn: anytype, | |
| 301 | params: anytype, | |
| 300 | hashFn: @compileError("anytype fields are removed from the language"), | |
| 301 | params: @compileError("anytype fields are removed from the language"), | |
| 302 | 302 | name: []const u8, |
| 303 | 303 | }; |
| 304 | 304 | const bcrypt_params = crypto.pwhash.bcrypt.Params{ .rounds_log = 12 }; |
lib/std/json.zig+2-1| ... | ... | @@ -1791,8 +1791,9 @@ fn parseInternal( |
| 1791 | 1791 | } |
| 1792 | 1792 | inline for (structInfo.fields) |field, i| { |
| 1793 | 1793 | if (!fields_seen[i]) { |
| 1794 | if (field.default_value) |default| { | |
| 1794 | if (field.default_value) |default_ptr| { | |
| 1795 | 1795 | if (!field.is_comptime) { |
| 1796 | const default = @ptrCast(*const field.field_type, default_ptr).*; | |
| 1796 | 1797 | @field(r, field.name) = default; |
| 1797 | 1798 | } |
| 1798 | 1799 | } else { |
lib/std/zig/Ast.zig-5| ... | ... | @@ -366,7 +366,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { |
| 366 | 366 | .builtin_call, |
| 367 | 367 | .builtin_call_comma, |
| 368 | 368 | .error_set_decl, |
| 369 | .@"anytype", | |
| 370 | 369 | .@"comptime", |
| 371 | 370 | .@"nosuspend", |
| 372 | 371 | .asm_simple, |
| ... | ... | @@ -729,7 +728,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { |
| 729 | 728 | .error_value, |
| 730 | 729 | => return datas[n].rhs + end_offset, |
| 731 | 730 | |
| 732 | .@"anytype", | |
| 733 | 731 | .anyframe_literal, |
| 734 | 732 | .char_literal, |
| 735 | 733 | .integer_literal, |
| ... | ... | @@ -2935,9 +2933,6 @@ pub const Node = struct { |
| 2935 | 2933 | /// main_token is the field name identifier. |
| 2936 | 2934 | /// lastToken() does not include the possible trailing comma. |
| 2937 | 2935 | container_field, |
| 2938 | /// `anytype`. both lhs and rhs unused. | |
| 2939 | /// Used by `ContainerField`. | |
| 2940 | @"anytype", | |
| 2941 | 2936 | /// `comptime lhs`. rhs unused. |
| 2942 | 2937 | @"comptime", |
| 2943 | 2938 | /// `nosuspend lhs`. rhs unused. |
lib/std/zig/parse.zig+2-13| ... | ... | @@ -786,19 +786,8 @@ const Parser = struct { |
| 786 | 786 | var align_expr: Node.Index = 0; |
| 787 | 787 | var type_expr: Node.Index = 0; |
| 788 | 788 | if (p.eatToken(.colon)) |_| { |
| 789 | if (p.eatToken(.keyword_anytype)) |anytype_tok| { | |
| 790 | type_expr = try p.addNode(.{ | |
| 791 | .tag = .@"anytype", | |
| 792 | .main_token = anytype_tok, | |
| 793 | .data = .{ | |
| 794 | .lhs = undefined, | |
| 795 | .rhs = undefined, | |
| 796 | }, | |
| 797 | }); | |
| 798 | } else { | |
| 799 | type_expr = try p.expectTypeExpr(); | |
| 800 | align_expr = try p.parseByteAlign(); | |
| 801 | } | |
| 789 | type_expr = try p.expectTypeExpr(); | |
| 790 | align_expr = try p.parseByteAlign(); | |
| 802 | 791 | } |
| 803 | 792 | |
| 804 | 793 | const value_expr: Node.Index = if (p.eatToken(.equal) == null) 0 else try p.expectExpr(); |
lib/std/zig/render.zig-2| ... | ... | @@ -229,8 +229,6 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index, |
| 229 | 229 | return renderToken(ais, tree, main_tokens[node] + 2, space); |
| 230 | 230 | }, |
| 231 | 231 | |
| 232 | .@"anytype" => return renderToken(ais, tree, main_tokens[node], space), | |
| 233 | ||
| 234 | 232 | .block_two, |
| 235 | 233 | .block_two_semicolon, |
| 236 | 234 | => { |
src/AstGen.zig+2-18| ... | ... | @@ -468,7 +468,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins |
| 468 | 468 | .for_simple, |
| 469 | 469 | .@"suspend", |
| 470 | 470 | .@"continue", |
| 471 | .@"anytype", | |
| 472 | 471 | .fn_proto_simple, |
| 473 | 472 | .fn_proto_multi, |
| 474 | 473 | .fn_proto_one, |
| ... | ... | @@ -558,8 +557,6 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr |
| 558 | 557 | .asm_output => unreachable, // Handled in `asmExpr`. |
| 559 | 558 | .asm_input => unreachable, // Handled in `asmExpr`. |
| 560 | 559 | |
| 561 | .@"anytype" => unreachable, // Handled in `containerDecl`. | |
| 562 | ||
| 563 | 560 | .assign => { |
| 564 | 561 | try assign(gz, scope, node); |
| 565 | 562 | return rvalue(gz, rl, .void_value, node); |
| ... | ... | @@ -3826,7 +3823,6 @@ fn structDeclInner( |
| 3826 | 3823 | const astgen = gz.astgen; |
| 3827 | 3824 | const gpa = astgen.gpa; |
| 3828 | 3825 | const tree = astgen.tree; |
| 3829 | const node_tags = tree.nodes.items(.tag); | |
| 3830 | 3826 | |
| 3831 | 3827 | var namespace: Scope.Namespace = .{ |
| 3832 | 3828 | .parent = scope, |
| ... | ... | @@ -3875,10 +3871,7 @@ fn structDeclInner( |
| 3875 | 3871 | return astgen.failTok(member.ast.name_token, "struct field missing type", .{}); |
| 3876 | 3872 | } |
| 3877 | 3873 | |
| 3878 | const field_type: Zir.Inst.Ref = if (node_tags[member.ast.type_expr] == .@"anytype") | |
| 3879 | .none | |
| 3880 | else | |
| 3881 | try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | |
| 3874 | const field_type = try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | |
| 3882 | 3875 | wip_members.appendToField(@enumToInt(field_type)); |
| 3883 | 3876 | |
| 3884 | 3877 | const doc_comment_index = try astgen.docCommentAsString(member.firstToken()); |
| ... | ... | @@ -3951,8 +3944,6 @@ fn unionDeclInner( |
| 3951 | 3944 | |
| 3952 | 3945 | const astgen = gz.astgen; |
| 3953 | 3946 | const gpa = astgen.gpa; |
| 3954 | const tree = astgen.tree; | |
| 3955 | const node_tags = tree.nodes.items(.tag); | |
| 3956 | 3947 | |
| 3957 | 3948 | var namespace: Scope.Namespace = .{ |
| 3958 | 3949 | .parent = scope, |
| ... | ... | @@ -4013,10 +4004,7 @@ fn unionDeclInner( |
| 4013 | 4004 | wip_members.nextField(bits_per_field, .{ have_type, have_align, have_value, unused }); |
| 4014 | 4005 | |
| 4015 | 4006 | if (have_type) { |
| 4016 | const field_type: Zir.Inst.Ref = if (node_tags[member.ast.type_expr] == .@"anytype") | |
| 4017 | .none | |
| 4018 | else | |
| 4019 | try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | |
| 4007 | const field_type = try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | |
| 4020 | 4008 | wip_members.appendToField(@enumToInt(field_type)); |
| 4021 | 4009 | } else if (arg_inst == .none and !have_auto_enum) { |
| 4022 | 4010 | return astgen.failNode(member_node, "union field missing type", .{}); |
| ... | ... | @@ -7791,7 +7779,6 @@ fn nodeMayNeedMemoryLocation(tree: *const Ast, start_node: Ast.Node.Index, have_ |
| 7791 | 7779 | .ptr_type, |
| 7792 | 7780 | .ptr_type_bit_range, |
| 7793 | 7781 | .@"suspend", |
| 7794 | .@"anytype", | |
| 7795 | 7782 | .fn_proto_simple, |
| 7796 | 7783 | .fn_proto_multi, |
| 7797 | 7784 | .fn_proto_one, |
| ... | ... | @@ -8052,7 +8039,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev |
| 8052 | 8039 | .ptr_type, |
| 8053 | 8040 | .ptr_type_bit_range, |
| 8054 | 8041 | .@"suspend", |
| 8055 | .@"anytype", | |
| 8056 | 8042 | .fn_proto_simple, |
| 8057 | 8043 | .fn_proto_multi, |
| 8058 | 8044 | .fn_proto_one, |
| ... | ... | @@ -8232,7 +8218,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In |
| 8232 | 8218 | .@"resume", |
| 8233 | 8219 | .array_type, |
| 8234 | 8220 | .@"suspend", |
| 8235 | .@"anytype", | |
| 8236 | 8221 | .fn_decl, |
| 8237 | 8222 | .anyframe_literal, |
| 8238 | 8223 | .integer_literal, |
| ... | ... | @@ -8474,7 +8459,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { |
| 8474 | 8459 | .@"resume", |
| 8475 | 8460 | .array_type, |
| 8476 | 8461 | .@"suspend", |
| 8477 | .@"anytype", | |
| 8478 | 8462 | .fn_decl, |
| 8479 | 8463 | .anyframe_literal, |
| 8480 | 8464 | .integer_literal, |
src/stage1/ir.cpp+4| ... | ... | @@ -19048,6 +19048,10 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 19048 | 19048 | return ira->codegen->invalid_inst_gen->value->type; |
| 19049 | 19049 | } |
| 19050 | 19050 | |
| 19051 | if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusAlignmentKnown))) { | |
| 19052 | return ira->codegen->invalid_inst_gen->value->type; | |
| 19053 | } | |
| 19054 | ||
| 19051 | 19055 | ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, |
| 19052 | 19056 | elem_type, |
| 19053 | 19057 | is_const, |
test/behavior/struct_llvm.zig-15| ... | ... | @@ -618,21 +618,6 @@ test "anonymous struct literal assigned to variable" { |
| 618 | 618 | try expect(vec.@"2" == 99); |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | test "struct with var field" { | |
| 622 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 623 | ||
| 624 | const Point = struct { | |
| 625 | x: anytype, | |
| 626 | y: anytype, | |
| 627 | }; | |
| 628 | const pt = Point{ | |
| 629 | .x = 1, | |
| 630 | .y = 2, | |
| 631 | }; | |
| 632 | try expect(pt.x == 1); | |
| 633 | try expect(pt.y == 2); | |
| 634 | } | |
| 635 | ||
| 636 | 621 | test "comptime struct field" { |
| 637 | 622 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| 638 | 623 |
test/behavior/type_info.zig-7| ... | ... | @@ -436,13 +436,6 @@ test "@typeInfo does not force declarations into existence" { |
| 436 | 436 | comptime try expect(@typeInfo(S).Struct.fields.len == 1); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | test "default value for a anytype field" { | |
| 440 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 441 | ||
| 442 | const S = struct { x: anytype }; | |
| 443 | try expect(@typeInfo(S).Struct.fields[0].default_value == null); | |
| 444 | } | |
| 445 | ||
| 446 | 439 | fn add(a: i32, b: i32) i32 { |
| 447 | 440 | return a + b; |
| 448 | 441 | } |
test/behavior/union_stage1.zig-5| ... | ... | @@ -419,8 +419,3 @@ test "union enum type gets a separate scope" { |
| 419 | 419 | |
| 420 | 420 | try S.doTheTest(); |
| 421 | 421 | } |
| 422 | ||
| 423 | test "anytype union field: issue #9233" { | |
| 424 | const Quux = union(enum) { bar: anytype }; | |
| 425 | _ = Quux; | |
| 426 | } |
test/compile_errors.zig-10| ... | ... | @@ -4207,16 +4207,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 4207 | 4207 | "tmp.zig:5:17: error: expected type 'void', found 'error{ShouldBeCompileError}'", |
| 4208 | 4208 | }); |
| 4209 | 4209 | |
| 4210 | ctx.objErrStage1("var makes structs required to be comptime known", | |
| 4211 | \\export fn entry() void { | |
| 4212 | \\ const S = struct{v: anytype}; | |
| 4213 | \\ var s = S{.v=@as(i32, 10)}; | |
| 4214 | \\ _ = s; | |
| 4215 | \\} | |
| 4216 | , &[_][]const u8{ | |
| 4217 | "tmp.zig:3:4: error: variable of type 'S' must be const or comptime", | |
| 4218 | }); | |
| 4219 | ||
| 4220 | 4210 | ctx.objErrStage1("@ptrCast discards const qualifier", |
| 4221 | 4211 | \\export fn entry() void { |
| 4222 | 4212 | \\ const x: i32 = 1234; |