aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2025-02-06x86_64: rewrite vector `@truncate`Jacob Young
2025-02-06x86_64: rewrite scalar `@truncate`Jacob Young
2025-02-06behavior: add test for old bugmlugg
Resolves: #18435
2025-02-06Sema: add missing `validateRuntimeValue` callsmlugg
Resolves: #13791
2025-02-06behavior: add test for old bugmlugg
Resolves: #13013
2025-02-06behavior: add test for old bugmlugg
Resolves: #2289
2025-02-05incremental: fix crash when introducing syntax errormlugg
Clearing the analysis roots was very clever and all, but not actually valid. We need to avoid *any* reference to the analysis errors if there were any fatal files, and that includes sorting the errors! Resolves: #22774
2025-02-05Sema: fix `@typeInfo` of function with generic return type and IESmlugg
Resolves: #20088
2025-02-05Sema: fix `@errorCast` with error unionsmlugg
Resolves: #20169
2025-02-05Sema: disable runtime safety checks in comptime blocksmlugg
Sometimes we emit runtime instructions in comptime scopes. These instructions will be discarded, but they allow comptime blocks to contain intermediate runtime-known values, which is necessary for expressions like `runtime_array.len` to work. Since we will always throw away these runtime instructions, including safety checks is a time waste at best and trips an assertion at worst! Resolves: #20064
2025-02-05Sema: fix comparison between error set and comptime-known error unionmlugg
Resolves: #20613
2025-02-05Sema: fix PTR of slice of sentinel-terminated arraymlugg
Resolves: #20901
2025-02-05compiler: provide result type to sentinel expression in slice operationmlugg
Resolves: #21867
2025-02-05Sema: fix crash on `@tagName` of undefined enum literalmlugg
Resolves: #20826
2025-02-05Sema: fix incorrectly succeeding type resolutionmlugg
Resolves: #21436
2025-02-05Merge pull request #22754 from mlugg/files-and-stuffMatthew Lugg
ZON and incremental bits
2025-02-05AstGen: improve error for invalid bytes in strings and commentsWill Lillis
2025-02-04test: remove failing casemlugg
Unfortunately, now that this error is more in line with other `@import` errors, it isn't so easy to have a test case for.
2025-02-04incremental: add ZON testmlugg
2025-02-03compiler,std: implement ZON supportMason Remaley
This commit allows using ZON (Zig Object Notation) in a few ways. * `@import` can be used to load ZON at comptime and convert it to a normal Zig value. In this case, `@import` must have a result type. * `std.zon.parse` can be used to parse ZON at runtime, akin to the parsing logic in `std.json`. * `std.zon.stringify` can be used to convert arbitrary data structures to ZON at runtime, again akin to `std.json`.
2025-02-02fix: error on non-exhaustive enums with zero width backing type (#21374)Will Lillis
Co-authored-by: WillLillis <wlillis@umass.edu>
2025-02-01Merge pull request #22672 from jacobly0/x86_64-rewriteAndrew Kelley
x86_64: rewrite float conversions
2025-02-01compiler: do not propagate result type to `try` operandmlugg
This commit effectively reverts 9e683f0, and hence un-accepts #19777. While nice in theory, this proposal turned out to have a few problems. Firstly, supplying a result type implicitly coerces the operand to this type -- that's the main point of result types! But for `try`, this is actually a bad idea; we want a redundant `try` to be a compile error, not to silently coerce the non-error value to an error union. In practice, this didn't always happen, because the implementation was buggy anyway; but when it did, it was really quite silly. For instance, `try try ... try .{ ... }` was an accepted expression, with the inner initializer being initially coerced to `E!E!...E!T`. Secondly, the result type inference here didn't play nicely with `return`. If you write `return try`, the operand would actually receive a result type of `E!E!T`, since the `return` gave a result type of `E!T` and the `try` wrapped it in *another* error union. More generally, the problem here is that `try` doesn't know when it should or shouldn't nest error unions. This occasionally broke code which looked like it should work. So, this commit prevents `try` from propagating result types through to its operand. A key motivation for the original proposal here was decl literals; so, as a special case, `try .foo(...)` is still an allowed syntax form, caught by AstGen and specially lowered. This does open the doors to allowing other special cases for decl literals in future, such as `.foo(...) catch ...`, but those proposals are for another time. Resolves: #21991 Resolves: #22633
2025-02-01Sema: skip aliasing check and runtime operation for `@memcpy` of zero-bit typemlugg
This check isn't valid in such cases, because the source and destination pointers both refer to zero bits of memory, meaning they effectively never alias. Resolves: #21655
2025-01-31x86_64: rewrite vector `@intCast`Jacob Young
2025-01-31x86_64: rewrite scalar `@intCast`Jacob Young
2025-01-31x86_64: rewrite float vector conversionsJacob Young
2025-01-31x86_64: rewrite scalar float conversionsJacob Young
2025-01-30compiler: add `intcast_safe` AIR instructionmlugg
This instruction is like `intcast`, but includes two safety checks: * Checks that the int is in range of the destination type * If the destination type is an exhaustive enum, checks that the int is a named enum value This instruction is locked behind the `safety_checked_instructions` backend feature; if unsupported, Sema will emit a fallback, as with other safety-checked instructions. This instruction is used to add a missing safety check for `@enumFromInt` truncating bits. This check also has a fallback for backends which do not yet support `safety_checked_instructions`. Resolves: #21946
2025-01-29x86_64: rewrite comparisonsJacob Young
2025-01-29Sema: explain why we tried to call an `extern fn` at comptimemlugg
I recently saw a user hit the "comptime call of extern function" error, and get confused because they didn't know why the scope was `comptime`. So, use `explainWhyBlockIsComptime` on this and related errors to add all the relevant notes. The added test case shows the motivating situation.
2025-01-29Sema: `@memcpy` changesmlugg
* The langspec definition of `@memcpy` has been changed so that the source and destination element types must be in-memory coercible, allowing all such calls to be raw copying operations, not actually applying any coercions. * Implement aliasing check for comptime `@memcpy`; a compile error will now be emitted if the arguments alias. * Implement more efficient comptime `@memcpy` by loading and storing a whole array at once, similar to how `@memset` is implemented.
2025-01-27Merge pull request #22610 from jacobly0/x86_64-rewriteAndrew Kelley
x86_64: rewrite `@min`/`@max` for scalar floats
2025-01-26fix: Only suggest try on destructure of error union if payload type can be ↵Will Lillis
destructured (#21510)
2025-01-26x86_64: rewrite `@min`/`@max` for float vectorsJacob Young
2025-01-26x86_64: rewrite `@min`/`@max` for scalar floatsJacob Young
2025-01-26Merge pull request #22602 from mlugg/incr-embedfileMatthew Lugg
incremental: handle `@embedFile`
2025-01-25Merge pull request #22581 from jacobly0/x86_64-rewriteAndrew Kelley
x86_64: rewrite `@abs` on floats
2025-01-25incr-check: check compile errors against expectedmlugg
Also modifies all incremental cases using `#expect_error` to include the errors and notes which are expected.
2025-01-25incremental: handle `@embedFile`mlugg
Uses of `@embedFile` register dependencies on the corresponding `Zcu.EmbedFile`. At the start of every update, we iterate all embedded files and update them if necessary, and invalidate the dependencies if they changed. In order to properly integrate with the lazy analysis model, failed embed files are now reported by the `AnalUnit` which actually used `@embedFile`; the filesystem error is stored in the `Zcu.EmbedFile`. An incremental test is added covering incremental updates to embedded files, and I have verified locally that dependency invalidation is working correctly.
2025-01-24x86_64: rewrite scalar and vector int `@min` and `@max`Jacob Young
2025-01-24x86_64: fix typo and lower optimized instsJacob Young
2025-01-24x86_64: rewrite float vector `@abs` and equality comparisonsJacob Young
2025-01-24x86_64: rewrite scalar float equality comparisonsJacob Young
2025-01-24all: update for `panic.unwrapError` and `panic.call` signature changesmlugg
2025-01-24compiler: yet more panic handler changesmlugg
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace. * `root.Panic` -> `root.panic` for the same reason. There are type checks so that we still allow the legacy `pub fn panic` strategy in the 0.14.0 release. * `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason. * `std.debug.NoPanic` -> `std.debug.no_panic`, same reason. * `std.debug.FormattedPanic` is now a function `std.debug.FullPanic` which takes as input a `panicFn` and returns a namespace with all the panic functions. This handles the incredibly common case of just wanting to override how the message is printed, whilst keeping nice formatted panics. * Remove `std.builtin.panic.messages`; now, every safety panic has its own function. This reduces binary bloat, as calls to these functions no longer need to prepare any arguments (aside from the error return trace). * Remove some legacy declarations, since a zig1.wasm update has happened. Most of these were related to the panic handler, but a quick grep for "zig1" brought up a couple more results too. Also, add some missing type checks to Sema. Resolves: #22584 formatted -> full
2025-01-23tests: enable stack trace tests for x86_64-selfhostedmlugg
Allows the stack trace tests to be additionally compiled and run with `.use_llvm = false, .use_lld = false` depending on the host target. This is currently enabled for x86_64 targets emitting ELF. Self-hosted backends emit slightly different DWARF info to the LLVM backend, so the checking logic (and the tests themselves) had to be tweaked slightly to support both backends at once.
2025-01-22Merge pull request #22572 from jacobly0/new-error-traceMatthew Lugg
compiler: include error trace in all functions, implement for x86_64 backend
2025-01-22Merge pull request #22571 from mlugg/various-fixes-againMatthew Lugg
compiler: a few fixes
2025-01-22x86_64: implement error return tracesJacob Young