View explanation.md

Note this:

call fastcc void @testEnumTagNameBare(%"[]u8"* %0, i2 -2), !dbg !29

We pass i2 -2 which is the unsigned value 2.

After optimizations, the value becomes i64 -2 which is the unsigned value 18446744073709551614.

View test1.ll
define i32 @main(i32, i32) {
%ok = icmp ult i32 %1, 32
br i1 %ok, label %ok_label, label %bad_label
ok_label:
ret i32 0
bad_label:
%a = lshr i32 %0, %1
ret i32 %a
}
View log.txt
<andrewrk> on freebsd, the default environment is "unknown"
<andrewrk> what are the implications of this?
<andrewrk> is it really not one of gnu gnuabi64 gnueabi gnueabihf gnux32 code16 eabi eabihf android musl musleabi musleabihf msvc itanium cygnus amdopencl coreclr ?
<compnerd> andrewrk: it just means that its not a specific environment, so the compiler can't make assumptions about what may be available
<andrewrk> compnerd, what's an example of something that would be available? what kind of things?
<compnerd> andrewrk: any gnu extensions in libc
<compnerd> andrewrk: or if the architecture is arm, can't assume that the environment conforms to EABI or EHABI
<andrewrk> compnerd, this is for generating libcalls only? does it have anything to do with ABI compatibility?
<compnerd> andrewrk: no, it can deal with ABI as well
<andrewrk> compnerd, how can the ABI be unknown? wouldn't there be *some* entry which corresponds to the ABI that we want to use?
View demo.zig
const assert = @import("std").debug.assert;
/// Compile-time parameters is how Zig implements generics. It is compile-time duck typing and it works mostly the same way that C++ template parameters work. Example:
//fn max(comptime T: type, a: T, b: T) -> T {
// if (a > b) a else b
//}
//fn gimmeTheBiggerFloat(a: f32, b: f32) -> f32 {
// max(f32, a, b)
//}
View istty.rs
pub fn isatty(handle: winapi::HANDLE) -> bool {
unsafe {
let handle = kernel32::GetStdHandle(handle);
// check for msys/cygwin
if is_cygwin_pty(handle) {
return true;
}
let mut out = 0;
View test.zig
const mem = @import("std").mem;
const assert = @import("std").debug.assert;
const AllocState = struct {
some_mem: [100 * 1024]u8,
index: usize,
fn alloc(a: &mem.Allocator, n: usize) -> %[]u8 {
const self = @ptrCast(&AllocState, a.context);
const result = self.some_mem[self.index ... self.index + n];
View output.txt
[nix-shell:~/dev/zig/build]$ ./zig test ../std/os/path.zig --test-filter resolve
Test 1/1 os.path.resolve...OK
[nix-shell:~/dev/zig/build]$ ./zig test ../std/os/path.zig 
/home/andy/dev/zig/std/buffer.zig:105:24: error: container 'Buffer' has no member called 'initFromBuffer'
    var buf2 = %%Buffer.initFromBuffer(&buf);
                       ^
/home/andy/dev/zig/std/buffer.zig:106:15: error: no member named 'eqlBuffer' in 'Buffer'
    assert(buf.eqlBuffer(&buf2));
              ^
View output.txt
[nix-shell:~/dev/zig/build]$ ./zig build --build-file ../build.zig --help
Usage: ./zig build [steps] [options]
Steps:
default Build the project
test Run all the tests
test-behavior Run the behavior tests
test-std Run the standard library tests
test-compare-output Run the compare output tests
test-build-examples Build the examples
View test.zig
pub fn panic(msg: []const u8) -> noreturn { @breakpoint(); while (true) {} }
comptime {
if (@sizeOf(@typeOf(foo)) == 0) unreachable;
}
// now you can have foo be any function you'd like to play with
fn foo() {
}
// build with: