| author | |
| committer | |
| log | 8a9289996ab8ed7da2f7e0c6df9fe2bd9a3e0b7b |
| tree | 28aa8644ce1ea7c3756c88a9948ad2d11a9b24c8 |
| parent | 24d5ec078355d68e3f1002220fd284b1ff02a465 |
| parent | 98183e47436699f6e5eab200061c46eec342806e |
| signature |
16 files changed, 207 insertions(+), 56 deletions(-)
README.md+2-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 |  |
| 2 | 2 | |
| 3 | Zig is an open-source programming language designed for **robustness**, | |
| 3 | A general-purpose programming language designed for **robustness**, | |
| 4 | 4 | **optimality**, and **maintainability**. |
| 5 | 5 | |
| 6 | 6 | ## Resources |
| ... | ... | @@ -10,6 +10,7 @@ Zig is an open-source programming language designed for **robustness**, |
| 10 | 10 | * [Community](https://github.com/ziglang/zig/wiki/Community) |
| 11 | 11 | * [Contributing](https://github.com/ziglang/zig/blob/master/CONTRIBUTING.md) |
| 12 | 12 | * [Frequently Asked Questions](https://github.com/ziglang/zig/wiki/FAQ) |
| 13 | * [Community Projects](https://github.com/ziglang/zig/wiki/Community-Projects) | |
| 13 | 14 | |
| 14 | 15 | ## Building from Source |
| 15 | 16 |
src/all_types.hpp+2-2| ... | ... | @@ -3745,8 +3745,8 @@ static const size_t slice_len_index = 1; |
| 3745 | 3745 | static const size_t maybe_child_index = 0; |
| 3746 | 3746 | static const size_t maybe_null_index = 1; |
| 3747 | 3747 | |
| 3748 | static const size_t err_union_err_index = 0; | |
| 3749 | static const size_t err_union_payload_index = 1; | |
| 3748 | static const size_t err_union_payload_index = 0; | |
| 3749 | static const size_t err_union_err_index = 1; | |
| 3750 | 3750 | |
| 3751 | 3751 | // label (grep this): [coro_frame_struct_layout] |
| 3752 | 3752 | static const size_t coro_fn_ptr_index = 0; |
src/analyze.cpp+7-6| ... | ... | @@ -7350,20 +7350,21 @@ static void resolve_llvm_types_error_union(CodeGen *g, ZigType *type) { |
| 7350 | 7350 | uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, type->llvm_type); |
| 7351 | 7351 | uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, type->llvm_type); |
| 7352 | 7352 | |
| 7353 | ZigLLVMDIType *di_element_types[] = { | |
| 7354 | ZigLLVMCreateDebugMemberType(g->dbuilder, ZigLLVMTypeToScope(type->llvm_di_type), | |
| 7353 | ZigLLVMDIType *di_element_types[2]; | |
| 7354 | di_element_types[err_union_err_index] = ZigLLVMCreateDebugMemberType(g->dbuilder, | |
| 7355 | ZigLLVMTypeToScope(type->llvm_di_type), | |
| 7355 | 7356 | "tag", di_file, line, |
| 7356 | 7357 | tag_debug_size_in_bits, |
| 7357 | 7358 | tag_debug_align_in_bits, |
| 7358 | 7359 | tag_offset_in_bits, |
| 7359 | ZigLLVM_DIFlags_Zero, get_llvm_di_type(g, err_set_type)), | |
| 7360 | ZigLLVMCreateDebugMemberType(g->dbuilder, ZigLLVMTypeToScope(type->llvm_di_type), | |
| 7360 | ZigLLVM_DIFlags_Zero, get_llvm_di_type(g, err_set_type)); | |
| 7361 | di_element_types[err_union_payload_index] = ZigLLVMCreateDebugMemberType(g->dbuilder, | |
| 7362 | ZigLLVMTypeToScope(type->llvm_di_type), | |
| 7361 | 7363 | "value", di_file, line, |
| 7362 | 7364 | value_debug_size_in_bits, |
| 7363 | 7365 | value_debug_align_in_bits, |
| 7364 | 7366 | value_offset_in_bits, |
| 7365 | ZigLLVM_DIFlags_Zero, get_llvm_di_type(g, payload_type)), | |
| 7366 | }; | |
| 7367 | ZigLLVM_DIFlags_Zero, get_llvm_di_type(g, payload_type)); | |
| 7367 | 7368 | |
| 7368 | 7369 | ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder, |
| 7369 | 7370 | compile_unit_scope, |
src/codegen.cpp+10-24| ... | ... | @@ -6690,29 +6690,12 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c |
| 6690 | 6690 | err_payload_value = gen_const_val(g, payload_val, ""); |
| 6691 | 6691 | make_unnamed_struct = is_llvm_value_unnamed_type(g, payload_val->type, err_payload_value); |
| 6692 | 6692 | } |
| 6693 | LLVMValueRef fields[2]; | |
| 6694 | fields[err_union_err_index] = err_tag_value; | |
| 6695 | fields[err_union_payload_index] = err_payload_value; | |
| 6693 | 6696 | if (make_unnamed_struct) { |
| 6694 | uint64_t payload_off = LLVMOffsetOfElement(g->target_data_ref, get_llvm_type(g, type_entry), 1); | |
| 6695 | uint64_t err_sz = LLVMStoreSizeOfType(g->target_data_ref, LLVMTypeOf(err_tag_value)); | |
| 6696 | unsigned pad_sz = payload_off - err_sz; | |
| 6697 | if (pad_sz == 0) { | |
| 6698 | LLVMValueRef fields[] = { | |
| 6699 | err_tag_value, | |
| 6700 | err_payload_value, | |
| 6701 | }; | |
| 6702 | return LLVMConstStruct(fields, 2, false); | |
| 6703 | } else { | |
| 6704 | LLVMValueRef fields[] = { | |
| 6705 | err_tag_value, | |
| 6706 | LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), pad_sz)), | |
| 6707 | err_payload_value, | |
| 6708 | }; | |
| 6709 | return LLVMConstStruct(fields, 3, false); | |
| 6710 | } | |
| 6697 | return LLVMConstStruct(fields, 2, false); | |
| 6711 | 6698 | } else { |
| 6712 | LLVMValueRef fields[] = { | |
| 6713 | err_tag_value, | |
| 6714 | err_payload_value, | |
| 6715 | }; | |
| 6716 | 6699 | return LLVMConstNamedStruct(get_llvm_type(g, type_entry), fields, 2); |
| 6717 | 6700 | } |
| 6718 | 6701 | } |
| ... | ... | @@ -8627,15 +8610,18 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 8627 | 8610 | } |
| 8628 | 8611 | } |
| 8629 | 8612 | |
| 8613 | //note(dimenus): appending libc headers before c_headers breaks intrinsics | |
| 8614 | //and other compiler specific items | |
| 8615 | // According to Rich Felker libc headers are supposed to go before C language headers. | |
| 8616 | args.append("-isystem"); | |
| 8617 | args.append(buf_ptr(g->zig_c_headers_dir)); | |
| 8618 | ||
| 8630 | 8619 | for (size_t i = 0; i < g->libc_include_dir_len; i += 1) { |
| 8631 | 8620 | Buf *include_dir = g->libc_include_dir_list[i]; |
| 8632 | 8621 | args.append("-isystem"); |
| 8633 | 8622 | args.append(buf_ptr(include_dir)); |
| 8634 | 8623 | } |
| 8635 | 8624 | |
| 8636 | // According to Rich Felker libc headers are supposed to go before C language headers. | |
| 8637 | args.append("-isystem"); | |
| 8638 | args.append(buf_ptr(g->zig_c_headers_dir)); | |
| 8639 | 8625 | |
| 8640 | 8626 | if (g->zig_target->is_native) { |
| 8641 | 8627 | args.append("-march=native"); |
src/ir.cpp+12-7| ... | ... | @@ -9098,6 +9098,9 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 9098 | 9098 | bool const_val_is_float = (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat); |
| 9099 | 9099 | assert(const_val_is_int || const_val_is_float); |
| 9100 | 9100 | |
| 9101 | if (const_val_is_int && other_type->id == ZigTypeIdComptimeFloat) { | |
| 9102 | return true; | |
| 9103 | } | |
| 9101 | 9104 | if (other_type->id == ZigTypeIdFloat) { |
| 9102 | 9105 | if (const_val->type->id == ZigTypeIdComptimeInt || const_val->type->id == ZigTypeIdComptimeFloat) { |
| 9103 | 9106 | return true; |
| ... | ... | @@ -11329,7 +11332,6 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 11329 | 11332 | if (enum_type->data.enumeration.layout == ContainerLayoutAuto && |
| 11330 | 11333 | enum_type->data.enumeration.src_field_count == 1) |
| 11331 | 11334 | { |
| 11332 | assert(tag_type == ira->codegen->builtin_types.entry_num_lit_int); | |
| 11333 | 11335 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| 11334 | 11336 | init_const_bigint(&result->value, tag_type, |
| 11335 | 11337 | &enum_type->data.enumeration.fields[0].value); |
| ... | ... | @@ -20697,12 +20699,15 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 20697 | 20699 | } |
| 20698 | 20700 | for (size_t i = 0; i < errors_len; i += 1) { |
| 20699 | 20701 | Stage2ErrorMsg *clang_err = &errors_ptr[i]; |
| 20700 | ErrorMsg *err_msg = err_msg_create_with_offset( | |
| 20701 | clang_err->filename_ptr ? | |
| 20702 | buf_create_from_mem(clang_err->filename_ptr, clang_err->filename_len) : buf_alloc(), | |
| 20703 | clang_err->line, clang_err->column, clang_err->offset, clang_err->source, | |
| 20704 | buf_create_from_mem(clang_err->msg_ptr, clang_err->msg_len)); | |
| 20705 | err_msg_add_note(parent_err_msg, err_msg); | |
| 20702 | 		// Clang can emit "too many errors, stopping now", in which case `source` and `filename_ptr` are null | |
| 20703 | 		if (clang_err->source && clang_err->filename_ptr) { | |
| 20704 | ErrorMsg *err_msg = err_msg_create_with_offset( | |
| 20705 | clang_err->filename_ptr ? | |
| 20706 | buf_create_from_mem(clang_err->filename_ptr, clang_err->filename_len) : buf_alloc(), | |
| 20707 | clang_err->line, clang_err->column, clang_err->offset, clang_err->source, | |
| 20708 | buf_create_from_mem(clang_err->msg_ptr, clang_err->msg_len)); | |
| 20709 | err_msg_add_note(parent_err_msg, err_msg); | |
| 20710 | 		} | |
| 20706 | 20711 | } |
| 20707 | 20712 | |
| 20708 | 20713 | return ira->codegen->invalid_instruction; |
std/c/freebsd.zig+1| ... | ... | @@ -6,3 +6,4 @@ pub const _errno = __error; |
| 6 | 6 | |
| 7 | 7 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; |
| 8 | 8 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 9 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) c_int; |
std/math.zig+67-3| ... | ... | @@ -242,12 +242,76 @@ pub fn floatExponentBits(comptime T: type) comptime_int { |
| 242 | 242 | }; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | pub fn min(x: var, y: var) @typeOf(x + y) { | |
| 246 | return if (x < y) x else y; | |
| 245 | /// Given two types, returns the smallest one which is capable of holding the | |
| 246 | /// full range of the minimum value. | |
| 247 | pub fn Min(comptime A: type, comptime B: type) type { | |
| 248 | switch (@typeInfo(A)) { | |
| 249 | .Int => |a_info| switch (@typeInfo(B)) { | |
| 250 | .Int => |b_info| if (!a_info.is_signed and !b_info.is_signed) { | |
| 251 | if (a_info.bits < b_info.bits) { | |
| 252 | return A; | |
| 253 | } else { | |
| 254 | return B; | |
| 255 | } | |
| 256 | }, | |
| 257 | else => {}, | |
| 258 | }, | |
| 259 | else => {}, | |
| 260 | } | |
| 261 | return @typeOf(A(0) + B(0)); | |
| 262 | } | |
| 263 | ||
| 264 | /// Returns the smaller number. When one of the parameter's type's full range fits in the other, | |
| 265 | /// the return type is the smaller type. | |
| 266 | pub fn min(x: var, y: var) Min(@typeOf(x), @typeOf(y)) { | |
| 267 | const Result = Min(@typeOf(x), @typeOf(y)); | |
| 268 | if (x < y) { | |
| 269 | // TODO Zig should allow this as an implicit cast because x is immutable and in this | |
| 270 | // scope it is known to fit in the return type. | |
| 271 | switch (@typeInfo(Result)) { | |
| 272 | .Int => return @intCast(Result, x), | |
| 273 | else => return x, | |
| 274 | } | |
| 275 | } else { | |
| 276 | // TODO Zig should allow this as an implicit cast because y is immutable and in this | |
| 277 | // scope it is known to fit in the return type. | |
| 278 | switch (@typeInfo(Result)) { | |
| 279 | .Int => return @intCast(Result, y), | |
| 280 | else => return y, | |
| 281 | } | |
| 282 | } | |
| 247 | 283 | } |
| 248 | 284 | |
| 249 | 285 | test "math.min" { |
| 250 | 286 | testing.expect(min(i32(-1), i32(2)) == -1); |
| 287 | { | |
| 288 | var a: u16 = 999; | |
| 289 | var b: u32 = 10; | |
| 290 | var result = min(a, b); | |
| 291 | testing.expect(@typeOf(result) == u16); | |
| 292 | testing.expect(result == 10); | |
| 293 | } | |
| 294 | { | |
| 295 | var a: f64 = 10.34; | |
| 296 | var b: f32 = 999.12; | |
| 297 | var result = min(a, b); | |
| 298 | testing.expect(@typeOf(result) == f64); | |
| 299 | testing.expect(result == 10.34); | |
| 300 | } | |
| 301 | { | |
| 302 | var a: i8 = -127; | |
| 303 | var b: i16 = -200; | |
| 304 | var result = min(a, b); | |
| 305 | testing.expect(@typeOf(result) == i16); | |
| 306 | testing.expect(result == -200); | |
| 307 | } | |
| 308 | { | |
| 309 | const a = 10.34; | |
| 310 | var b: f32 = 999.12; | |
| 311 | var result = min(a, b); | |
| 312 | testing.expect(@typeOf(result) == f32); | |
| 313 | testing.expect(result == 10.34); | |
| 314 | } | |
| 251 | 315 | } |
| 252 | 316 | |
| 253 | 317 | pub fn max(x: var, y: var) @typeOf(x + y) { |
| ... | ... | @@ -309,7 +373,7 @@ test "math.shl" { |
| 309 | 373 | } |
| 310 | 374 | |
| 311 | 375 | /// Shifts right. Overflowed bits are truncated. |
| 312 | /// A negative shift amount results in a lefft shift. | |
| 376 | /// A negative shift amount results in a left shift. | |
| 313 | 377 | pub fn shr(comptime T: type, a: T, shift_amt: var) T { |
| 314 | 378 | const abs_shift_amt = absCast(shift_amt); |
| 315 | 379 | const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt); |
std/os.zig+13| ... | ... | @@ -120,6 +120,19 @@ pub fn getrandom(buf: []u8) GetRandomError!void { |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | if (freebsd.is_the_target) { | |
| 124 | while (true) { | |
| 125 | const err = std.c.getErrno(std.c.getrandom(buf.ptr, buf.len, 0)); | |
| 126 | ||
| 127 | switch (err) { | |
| 128 | 0 => return, | |
| 129 | EINVAL => unreachable, | |
| 130 | EFAULT => unreachable, | |
| 131 | EINTR => continue, | |
| 132 | else => return unexpectedErrno(err), | |
| 133 | } | |
| 134 | } | |
| 135 | } | |
| 123 | 136 | if (wasi.is_the_target) { |
| 124 | 137 | switch (wasi.random_get(buf.ptr, buf.len)) { |
| 125 | 138 | 0 => return, |
std/os/bits/netbsd.zig+59| ... | ... | @@ -760,3 +760,62 @@ pub const stack_t = extern struct { |
| 760 | 760 | ss_size: isize, |
| 761 | 761 | ss_flags: i32, |
| 762 | 762 | }; |
| 763 | ||
| 764 | pub const S_IFMT = 0o170000; | |
| 765 | ||
| 766 | pub const S_IFIFO = 0o010000; | |
| 767 | pub const S_IFCHR = 0o020000; | |
| 768 | pub const S_IFDIR = 0o040000; | |
| 769 | pub const S_IFBLK = 0o060000; | |
| 770 | pub const S_IFREG = 0o100000; | |
| 771 | pub const S_IFLNK = 0o120000; | |
| 772 | pub const S_IFSOCK = 0o140000; | |
| 773 | pub const S_IFWHT = 0o160000; | |
| 774 | ||
| 775 | pub const S_ISUID = 0o4000; | |
| 776 | pub const S_ISGID = 0o2000; | |
| 777 | pub const S_ISVTX = 0o1000; | |
| 778 | pub const S_IRWXU = 0o700; | |
| 779 | pub const S_IRUSR = 0o400; | |
| 780 | pub const S_IWUSR = 0o200; | |
| 781 | pub const S_IXUSR = 0o100; | |
| 782 | pub const S_IRWXG = 0o070; | |
| 783 | pub const S_IRGRP = 0o040; | |
| 784 | pub const S_IWGRP = 0o020; | |
| 785 | pub const S_IXGRP = 0o010; | |
| 786 | pub const S_IRWXO = 0o007; | |
| 787 | pub const S_IROTH = 0o004; | |
| 788 | pub const S_IWOTH = 0o002; | |
| 789 | pub const S_IXOTH = 0o001; | |
| 790 | ||
| 791 | pub fn S_ISFIFO(m: u32) bool { | |
| 792 | return m & S_IFMT == S_IFIFO; | |
| 793 | } | |
| 794 | ||
| 795 | pub fn S_ISCHR(m: u32) bool { | |
| 796 | return m & S_IFMT == S_IFCHR; | |
| 797 | } | |
| 798 | ||
| 799 | pub fn S_ISDIR(m: u32) bool { | |
| 800 | return m & S_IFMT == S_IFDIR; | |
| 801 | } | |
| 802 | ||
| 803 | pub fn S_ISBLK(m: u32) bool { | |
| 804 | return m & S_IFMT == S_IFBLK; | |
| 805 | } | |
| 806 | ||
| 807 | pub fn S_ISREG(m: u32) bool { | |
| 808 | return m & S_IFMT == S_IFREG; | |
| 809 | } | |
| 810 | ||
| 811 | pub fn S_ISLNK(m: u32) bool { | |
| 812 | return m & S_IFMT == S_IFLNK; | |
| 813 | } | |
| 814 | ||
| 815 | pub fn S_ISSOCK(m: u32) bool { | |
| 816 | return m & S_IFMT == S_IFSOCK; | |
| 817 | } | |
| 818 | ||
| 819 | pub fn S_IWHT(m: u32) bool { | |
| 820 | return m & S_IFMT == S_IFWHT; | |
| 821 | } |
std/os/netbsd.zig+1| ... | ... | @@ -2,3 +2,4 @@ const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("../std.zig"); |
| 3 | 3 | pub const is_the_target = builtin.os == .netbsd; |
| 4 | 4 | pub usingnamespace std.c; |
| 5 | pub usingnamespace @import("bits.zig"); |
std/os/windows.zig+12-3| ... | ... | @@ -138,10 +138,19 @@ pub const RtlGenRandomError = error{Unexpected}; |
| 138 | 138 | /// https://github.com/rust-lang-nursery/rand/issues/111 |
| 139 | 139 | /// https://bugzilla.mozilla.org/show_bug.cgi?id=504270 |
| 140 | 140 | pub fn RtlGenRandom(output: []u8) RtlGenRandomError!void { |
| 141 | if (advapi32.RtlGenRandom(output.ptr, output.len) == 0) { | |
| 142 | switch (kernel32.GetLastError()) { | |
| 143 | else => |err| return unexpectedError(err), | |
| 141 | var total_read: usize = 0; | |
| 142 | var buff: []u8 = output[0..]; | |
| 143 | const max_read_size: ULONG = maxInt(ULONG); | |
| 144 | ||
| 145 | while (total_read < output.len) { | |
| 146 | const to_read: ULONG = math.min(buff.len, max_read_size); | |
| 147 | ||
| 148 | if (advapi32.RtlGenRandom(buff.ptr, to_read) == 0) { | |
| 149 | return unexpectedError(kernel32.GetLastError()); | |
| 144 | 150 | } |
| 151 | ||
| 152 | total_read += to_read; | |
| 153 | buff = buff[to_read..]; | |
| 145 | 154 | } |
| 146 | 155 | } |
| 147 | 156 |
std/os/windows/advapi32.zig+1-1| ... | ... | @@ -19,5 +19,5 @@ pub extern "advapi32" stdcallcc fn RegQueryValueExW( |
| 19 | 19 | |
| 20 | 20 | // RtlGenRandom is known as SystemFunction036 under advapi32 |
| 21 | 21 | // http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */ |
| 22 | pub extern "advapi32" stdcallcc fn SystemFunction036(output: [*]u8, length: usize) BOOL; | |
| 22 | pub extern "advapi32" stdcallcc fn SystemFunction036(output: [*]u8, length: ULONG) BOOL; | |
| 23 | 23 | pub const RtlGenRandom = SystemFunction036; |
test/compile_errors.zig-8| ... | ... | @@ -3292,14 +3292,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3292 | 3292 | "tmp.zig:3:17: note: value 8 cannot fit into type u3", |
| 3293 | 3293 | ); |
| 3294 | 3294 | |
| 3295 | cases.add( | |
| 3296 | "incompatible number literals", | |
| 3297 | \\const x = 2 == 2.0; | |
| 3298 | \\export fn entry() usize { return @sizeOf(@typeOf(x)); } | |
| 3299 | , | |
| 3300 | "tmp.zig:1:11: error: integer value 2 cannot be implicitly casted to type 'comptime_float'", | |
| 3301 | ); | |
| 3302 | ||
| 3303 | 3295 | cases.add( |
| 3304 | 3296 | "missing function call param", |
| 3305 | 3297 | \\const Foo = struct { |
test/stage1/behavior/cast.zig+6-1| ... | ... | @@ -508,7 +508,7 @@ test "peer type resolution: unreachable, null, slice" { |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | test "peer type resolution: unreachable, error set, unreachable" { |
| 511 | const Error = error { | |
| 511 | const Error = error{ | |
| 512 | 512 | FileDescriptorAlreadyPresentInSet, |
| 513 | 513 | OperationCausesCircularLoop, |
| 514 | 514 | FileDescriptorNotRegistered, |
| ... | ... | @@ -529,3 +529,8 @@ test "peer type resolution: unreachable, error set, unreachable" { |
| 529 | 529 | }; |
| 530 | 530 | expect(transformed_err == error.SystemResources); |
| 531 | 531 | } |
| 532 | ||
| 533 | test "implicit cast comptime_int to comptime_float" { | |
| 534 | comptime expect(comptime_float(10) == f32(10)); | |
| 535 | expect(2 == 2.0); | |
| 536 | } |
test/stage1/behavior/enum.zig+11| ... | ... | @@ -982,3 +982,14 @@ test "enum literal casting to tagged union" { |
| 982 | 982 | else => @panic("fail"), |
| 983 | 983 | } |
| 984 | 984 | } |
| 985 | ||
| 986 | test "enum with one member and custom tag type" { | |
| 987 | const E = enum(u2) { | |
| 988 | One, | |
| 989 | }; | |
| 990 | expect(@enumToInt(E.One) == 0); | |
| 991 | const E2 = enum(u2) { | |
| 992 | One = 2, | |
| 993 | }; | |
| 994 | expect(@enumToInt(E2.One) == 2); | |
| 995 | } |
tools/process_headers.zig+3| ... | ... | @@ -504,6 +504,9 @@ const Contents = struct { |
| 504 | 504 | } |
| 505 | 505 | }; |
| 506 | 506 | |
| 507 | comptime { | |
| 508 | @compileError("the behavior of std.AutoHashMap changed and []const u8 will be treated as a pointer. will need to update the hash maps to actually do some kind of hashing on the slices."); | |
| 509 | } | |
| 507 | 510 | const HashToContents = std.AutoHashMap([]const u8, Contents); |
| 508 | 511 | const TargetToHash = std.HashMap(DestTarget, []const u8, DestTarget.hash, DestTarget.eql); |
| 509 | 512 | const PathTable = std.AutoHashMap([]const u8, *TargetToHash); |