aboutsummaryrefslogtreecommitdiff
path: root/test/behavior.zig
AgeCommit message (Collapse)Author
2021-12-08stage1: saturating shl operates using LHS typeAndrew Kelley
Saturating shift left (`<<|`) previously used the `ir_analyze_bin_op_math` codepath rather than the `ir_analyze_bit_shift` codepath, leading to it doing peer type resolution (incorrect) instead of using the LHS type as the number of bits to do the saturating against. This required implementing SIMD vector support for `@truncate`. Additionall, this commit adds a compile error for saturating shift left on a comptime_int. stage2 does not pass these new behavior tests yet. closes #10298
2021-12-05wasm: Initial behavior tests succeedingLuuk de Gram
- Correctly load slice value on stack - Implement WrapErrorUnionErr and payload - Implement trunc, fix sliceLen and write undefined - Implement slice as return type and argument Note: This also fixes a memory leak for inferred error sets, and for usingnamespace
2021-12-04Revert "Merge pull request #10270 from Luukdegram/behaviour-tests"Andrew Kelley
This reverts commit 725267f7c20f0ba588b472048a8c1fe1a328c714, reversing changes made to 2dae860de3494f97c9477af9282fe0131ff5c4cb. This test is failing: ```zig pub fn main() u8 { var e = foo(); const i = e catch 69; return i; } fn foo() anyerror!u8 { return 5; } ``` It's returning 69 instead of the expected value 5.
2021-12-04wasm: Initial behavior tests succeedingLuuk de Gram
Note: This also fixes a memory leak for inferred error sets, and for usingnamespace
2021-11-30put the passing stage2 behavior tests backAndrew Kelley
This mostly reverts commit 692c254336da71cbe21aaf9fbc21240fd1269b95. The test "for loop over pointers to struct, getting field from struct pointer" is still failing on the CI so that one is not moved over.
2021-11-30Revert "I found some more passing behavior tests"Andrew Kelley
This reverts commit 0a9b4d092f58595888f9e4be8ef683b2ed8a0da1. Hm, these are all passing for me locally. I'll have to do some troubleshooting to figure out which one(s) are failing on the CI.
2021-11-29I found some more passing behavior testsAndrew Kelley
2021-11-27stage2: implement `@typeName`Andrew Kelley
* stage1: change the `@typeName` of `@TypeOf(undefined)`, `@TypeOf(null)`, and `@TypeOf(.foo)` to match stage2. * move passing behavior tests to the passing-for-stage2 section.
2021-11-26Sema: fix analyzeBlockBody logicAndrew Kelley
Previously, when a coercion needed to be inserted into a break instruction, the `br` AIR instruction would be rewritten so that the block operand was a sub-block that did the coercion. The problem is that the sub-block itself was never added to the parent block, resulting in the `br` instruction operand being a bad reference. Now, the `br` AIR instruction that needs to have coercion instructions added is replaced with the sub-block itself with type `noreturn`, and then the sub-block has the coercion instructions and a new `br` instruction that breaks from the original block. LLVM backend needed to be fixed to lower `noreturn` blocks without emitting an unused LLVM basic block.
2021-11-23C backend: errors and optionalsScibuild
* bitcast treats all pointers as pointers * correctly unwrapping error unions with pointers * equality operators for primitive optional types
2021-11-22Sema: fix alignment of type-inferred localsAndrew Kelley
2021-11-22Merge pull request #10165 from jmc-88/cbeAndrew Kelley
CBE: add .optional_single_mut_pointer and .optional_single_const_pointer to Type.childType
2021-11-22stage2: move some tests which are now passingRobin Voetter
2021-11-17CBE: mark align.zig and error.zig as passingDaniele Cocca
Newly passing as of 3794a32d89632db9b033da433bdaa8f6d83d36e4.
2021-11-16cast -> cast_llvm, cast_c -> cast (doesn't work on LLVM backend)drew
2021-11-16add generics behavior testdrew
-airLoad and airStore now properly report an error if they are used with an array, instead of having the C compiler emit a vague error -airStoreUndefined now works with array types -structFieldPtr now works with array types, allowing generics' tests to pass
2021-11-16small changes + align tests obviously shouldn't have passeddrew
2021-11-16C backend: basic big ints, fix airPtrToInt, array references, pointer ↵drew
arithmetic UB with NULL, implement airPtrElemPtr/Val, fix redundant indirection/references with arrays -add additional test cases that were found to be passing -add basic int128 test cases which previously did not pass but weren't covered -most test cases in cast.zig now pass -i128/u128 or smaller int constants can now be rendered -unsigned int constants are now always suffixed with 'u' to prevent random compile errors -pointers with a val tag of 'zero' now just emit a 0 constant which coerces to the pointer type and fixes some warnings with ordered comparisons -pointers with a val tag of 'one' are now casted back to the pointer type -support pointers with a u64 val -fix bug where rendering an array's type will emit more indirection than is needed -render uint128_t/int128_t manually when needed -implement ptr_add/sub AIR handlers manually so they manually cast to int types which avoids UB if the result or ptr operand is NULL -implement airPtrElemVal/Ptr -airAlloc for arrays will not allocate a ref as the local for the array is already a reference/pointer to the array itself -fix airPtrToInt by casting to the int type
2021-11-16stage1: Fix caching of LLVM builtin fnsLemonBoy
The cache entry must take into account the fact some functions operate on scalar types and some other on vectors of scalar types. Fixes #10147
2021-11-14CBE: memset(..., 0xaa, ...) undefined valuesDaniele Cocca
This commit makes airStore() handle undefined values directly instead of delegating to renderValue(): the call to renderValue() happens too late, when "dest = " has already been written to the stream, at which point there's no sane way to initialize e.g. struct values by assignment. Instead, we make airStore() use memset(dest, 0xaa, sizeof(dest)), which should transparently handle all types. Also moves the newly-passing tests to the top of test/behavior.zig.
2021-11-08C backend: while, struct tests, better undefined global handlingEmily Bellows
1. Function signatures that return a no member struct return void 2. Undefined var decls don't get a value generated for them 3. Don't generate bitcast code if the result isn't used, since bitcast is a pure function. Right now struct handling code generates some weird unused bitcast AIR, and this optimization side steps that issue.
2021-11-04Add more entries to the list of stage1+stage2+CBE passing tests (#10094)Daniele Cocca
* CBE: mark call.zig tests as passing * CBE: mark enum.zig tests as passing * CBE: mark defer.zig tests as passing * CBE: mark hasdecl.zig tests as passing * CBE: mark hasfield.zig tests as passing * CBE: mark ptrcast.zig tests as passing * CBE: mark bitcast.zig tests as passing * CBE: mark pub_enum.zig tests as passing * CBE: mark underscore.zig tests as passing * CBE: mark usingnamespace.zig tests as passing * CBE: mark bugs/655.zig tests as passing * CBE: mark bugs/679.zig tests as passing * CBE: mark bugs/704.zig tests as passing * CBE: mark bugs/1486.zig tests as passing * CBE: mark bugs/2346.zig tests as passing * CBE: mark bugs/2889.zig tests as passing * CBE: mark bugs/4560.zig tests as passing * CBE: mark bugs/4769_a.zig tests as passing * CBE: mark bugs/4769_b.zig tests as passing * CBE: mark bugs/6850.zig tests as passing
2021-11-02C backend: implement ?void, and other zero sized typesEmily Bellows
2021-10-30C backend: implement signed truncEmily Bellows
2021-10-29stage2: implement `@popCount` for non-vectorsAndrew Kelley
2021-10-28C backend: implement trunc instructionAndrew Kelley
Note that there is not any test coverage yet for integer truncation involving non-power-of-two integers.
2021-10-28C backend: fix `@boolToInt`Andrew Kelley
2021-10-28C backend: fix crash when number of Decls passes a thresholdAndrew Kelley
The ensureUnusedCapacity did not reserve a big enough number. I changed it to no longer guess the capacity because I saw that the number of possible items was not determinable ahead of time and this can therefore avoid allocating more memory than necessary.
2021-10-28C backend: fix ptrtoint and wrap_errunion_errAndrew Kelley
2021-10-28behavior tests: add "passing for C backend" categoryAndrew Kelley
2021-10-25stage2: comptime slice of pointer to hardcoded addressRobin Voetter
2021-10-22stage2: slice and alignment fixesAndrew Kelley
* Fix backend using wrong union field of the slice instruction. * LLVM backend properly sets alignment on global variables. * Sema: add coercion for *T to *[1]T * Sema: pointers to Decls with explicit alignment now have alignment metadata in them.
2021-10-22stage2: change `@bitCast` to always be by-valueAndrew Kelley
After a discussion about language specs, this seems like the best way to go, because it's simpler to reason about both for humans and compilers. The `bitcast_result_ptr` ZIR instruction is no longer needed. This commit also implements writing enums, arrays, and vectors to virtual memory at compile-time. This unlocked some more of compiler-rt being able to build, which in turn unlocks saturating arithmetic behavior tests. There was also a memory leak in the comptime closure system which is now fixed.
2021-10-21stage2: implement comptime loads through casted pointersAndrew Kelley
2021-10-21stage2: more division supportAndrew Kelley
AIR: * div is renamed to div_trunc. * Add div_float, div_floor, div_exact. - Implemented in Sema and LLVM codegen. C backend has a stub. Improvements to std.math.big.Int: * Add `eqZero` function to `Mutable`. * Fix incorrect results for `divFloor`. Compiler-rt: * Add muloti4 to the stage2 section.
2021-10-21stage2: truncationRobin Voetter
* Also fixes a related case where big int truncate would assume that the input fits in the output limbs buffer
2021-10-20AstGen: make the index variable of `inline for` a `alloc_comptime`Andrew Kelley
Before it was being emitted as an `alloc` which caused inline for loops to not work correctly.
2021-10-18astgen.zig: fix false positive in breakExpr's checking for store_to_block_ptrMatthew Borkowski
2021-10-17Sema: resolveTypeFields before accessing type fieldsAndrew Kelley
2021-10-17stage2: implement `@hasField`Meghan Denny
struct and union are kept in stage1 because struct/unionFieldCount are returning zero
2021-10-17alphebetize behavior testsMeghan Denny
2021-10-17stage2: LLVM backend: lower constant field/elem ptrsAndrew Kelley
2021-10-16Sema: coercion from error sets to `anyerror`Andrew Kelley
2021-10-16Merge pull request #9954 from Snektron/shiftsAndrew Kelley
Big int saturating left shift
2021-10-16elevate more passing testsMeghan Denny
2021-10-16stage2: comptime saturating shlRobin Voetter
2021-10-16stage2: `@hasDecl` is passingMeghan
2021-10-14stage2: LLVM backend: implement `wrap_optional` AIRAndrew Kelley
and move over some passing tests
2021-10-14stage2: implement `@minimum` and `@maximum`, including vectorsAndrew Kelley
* std.os: take advantage of `@minimum`. It's probably time to deprecate `std.min` and `std.max`. * New AIR instructions: min and max * Introduce SIMD vector support to stage2 * Add `@Type` support for vectors * Sema: add `checkSimdBinOp` which can be re-used for other arithmatic operators that want to support vectors. * Implement coercion from vectors to arrays. - In backends this is handled with bitcast for vector to array, however maybe we want to reduce the amount of branching by introducing an explicit AIR instruction for it in the future. * LLVM backend: implement lowering vector types * Sema: Implement `slice.ptr` at comptime * Value: improve `numberMin` and `numberMax` to support floats in addition to integers, and make them behave properly in the presence of NaN.
2021-10-13move behavior tests that are passing for stage2Andrew Kelley