Commit Graph

1381 Commits

Author SHA1 Message Date
Andrew Kelley 4d5e0a0434 Revert the last two commits in this branch
When the slice-by-length start position is runtime-known, it is likely
protected by a runtime-known condition and therefore a compile error is
less appropriate than a runtime panic check.

This is demonstrated in the json code that was updated and then reverted
in this commit.

When #3806 is implemented, this decision can be reassessed.

Revert "std: work around compiler unable to evaluate condition at compile time"
Revert "frontend: comptime array slice-by-length OOB detection"

This reverts commit 7741aca96c.
This reverts commit 2583b389ea.
2024-03-20 17:29:06 -07:00
Andrew Kelley 2583b389ea frontend: comptime array slice-by-length OOB detection 2024-03-20 17:02:35 -07:00
Andrew Kelley ab22844176 frontend: add missing bounds check for slice-by-length arrays
closes #18382
2024-03-20 16:29:46 -07:00
Andrew Kelley 8c94950c24 fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
Veikka Tuominen 64173dadca Merge pull request #19334 from antlilja/llvm-fast-math
Fix setFloatMode in LLVM backend
2024-03-18 04:27:39 +02:00
Andrew Kelley 95cb939440 Merge pull request #19333 from Vexu/fixes
Miscellaneous error fixes
2024-03-17 15:26:55 -07:00
Andrew Kelley d981549d65 Merge pull request #19323 from jacobly0/rm-fn-type-align
AstGen: disallow alignment on function types
2024-03-17 15:19:54 -07:00
antlilja 8ac5eb0893 LLVM: Add test for calling reduce with float mode set to optimized 2024-03-17 16:34:36 +01:00
Veikka Tuominen f983adfc10 Sema: fix printing of inferred error set of generic fn
Closes #19332
2024-03-17 13:33:05 +02:00
Anton Lilja 294f51814f LLVM lowerDebugType: Lower union types without a layout into an empty namespace 2024-03-17 13:25:09 +02:00
Jacob Young d10c52c194 AstGen: disallow alignment on function types
A pointer type already has an alignment, so this information does not
need to be duplicated on the function type.  This already has precedence
with addrspace which is already disallowed on function types for this
reason.  Also fixes `@TypeOf(&func)` to have the correct addrspace and
alignment.
2024-03-17 03:06:17 +01:00
mlugg 48af67c152 Zcu: rename implicitly-named decls to avoid overriding by explicit decls 2024-03-14 07:40:05 +00:00
mlugg 00969062a9 compiler: detect duplicate test names in AstGen
There is no reason to perform this detection during semantic analysis.
In fact, doing so is problematic, because we wish to utilize detection
of existing decls in a namespace in incremental compilation.
2024-03-14 07:40:05 +00:00
Andrew Kelley bd24e66379 Merge pull request #19229 from tiehuis/ryu-128
std.fmt: add ryu floating-point formatting implementation
2024-03-11 18:46:26 -07:00
Tristan Ross 6067d39522 std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross 099f3c4039 std.builtin: make container layout fields lowercase 2024-03-11 07:09:07 -07:00
Marc Tiehuis da4acf9a48 std.fmt: fix std-cases and perform round-trip check in ryu unit tests 2024-03-09 22:23:14 +13:00
february cozzocrea b2427ea7d8 test manifest key checking and other fixes
This commit adds several fixes and improvements for the Zig compiler
test harness.

1. -Dskip-translate-c option added for skipping the translate-c tests.
2. translate-c/run-translated-c tests in test/cases/* have been added to
   the steps test-translate-c and test-run-translated-c. Closes #18224.
3. Custom name added to the CheckFile step for the translate-c step to
   better communicate which test failed.
4. Test manifest key validation added to return an error if a manifest
   contains an invalid key.
2024-03-08 02:59:45 -08:00
mlugg e1d8187028 cases: correct after #18816
I changed an error messages and fixed a minor bug while implementing
this proposal, which led to a few compile error cases failing.
2024-03-06 21:26:38 +00:00
John Schmidt 7a045ede7c Check for inactive union field when calling fn at comptime
Reuse `unionFieldPtr` here to ensure that all the safety checks are
included.

Closes https://github.com/ziglang/zig/issues/18546.
2024-02-26 16:55:17 -08:00
Andrew Kelley 3e79c0f18c Merge pull request #18859 from schmee/switch-union-capture-align
Sema: preserve field alignment in union pointer captures
2024-02-26 16:52:39 -08:00
John Schmidt 00ff123b1e Sema: fix compile error for switching on undefined union
Before this fix, passing an undefined union value to `Sema.switchCond`
returned an undefined value of the union type, not the tag type, since
`Value.unionTag` forwards undefined values unchanged.
This leads us into the `.Union` branch in `Sema.zirSwitchBlock` which is
unreachable, now we take the `.Enum` branch instead.
2024-02-26 16:51:37 -08:00
mlugg 65a87ff299 Liveness: do not elide safety-checked instructions
Resolves: #19012
2024-02-20 12:10:29 +00:00
mlugg 7461309b73 Sema: validate that runtime-known inferred alloc does not have comptime-only type
Resolves: #18997
2024-02-19 21:48:50 +00:00
mlugg b2f28a104d cases: account for changed compile errors 2024-02-16 12:15:39 +00:00
Veikka Tuominen 51d67c7c8f Sema: add declared here notes in fail
This ensures that the note is added in more places and that `errMsg` needs to be used in fewer places.
2024-02-12 12:54:32 -08:00
Veikka Tuominen 731ff120d0 Sema: catch runtime stores to comptime variables through calls 2024-02-09 13:51:51 -08:00
Andrew Kelley 54bbc73f85 Merge pull request #18712 from Vexu/std.options
std: make options a struct instance instead of a namespace
2024-02-09 13:38:42 -08:00
John Schmidt dbcd53def0 Preserve field alignment in union pointer captures 2024-02-08 23:49:03 +01:00
David Rubin 24fb6d1f30 Make @intFromEnum an error for empty enums 2024-02-06 21:04:09 +02:00
David Rubin 122387943b Fix OOB when enum field out of order in different file 2024-02-03 19:52:05 +00:00
David Rubin eb4024036d Add error hint when looping over ErrorUnion 2024-02-03 19:16:27 +00:00
Veikka Tuominen 07dbff4f44 std.start: remove event loop integration 2024-02-01 15:22:36 +02:00
danielsan901998 d7a27bf803 Use mem.zeroes for empty union initializer list 2024-01-31 06:38:44 +02:00
Pavel Verigo 96a5f7c8ed Sema: fix casting runtime value to enum with comptime int tag type 2024-01-29 01:43:19 +02:00
Krzysztof Wolicki 61ba225709 Sema: tuples have no names to be used for reporting errors in finishStructInit 2024-01-26 15:22:15 +02:00
Veikka Tuominen eeec34ccb6 Sema: implement comptime error return traces 2024-01-22 18:08:56 -08:00
David Rubin 1b8f7e46fa AstGen: detect duplicate field names
This logic was previously in Sema, which was unnecessary complexity, and meant the issue was not detected unless the declaration was semantically analyzed. This commit finishes the work which 941090d started.

Resolves: #17916
2024-01-20 17:23:47 +00:00
Meghan Denny 46d592e485 do not enforce function parameters to be marked comptime if only called at comptime 2024-01-19 15:31:18 -08:00
David Rubin 6e5bdb5397 add type check to zirSwitchBlockErrUnion 2024-01-18 00:46:00 +00:00
Techatrix ec358d6db5 sema: fix safe integer arithmetic operations on undefined values
Previously `@as(i64, undefined) +% 1` would produce `@as(@TypeOf(undefined), undefined)` which now gives `@as(i64, undefined)`.
Previously `@as(i64, undefined) +| 1` would hit an assertion which now gives `@as(i64, undefined)`.
2024-01-16 16:27:31 -08:00
travisstaloch f3353708d8 AstGen: use correct token_src for switch, if and while exprs
fixes #18579
2024-01-16 18:22:44 +02:00
february cozzocrea da506aaf6e translate-c: Explicit cast bool from float fix 2024-01-16 18:12:05 +02:00
february cozzocrea 50457482b1 translate-c: Fix for compound assign implicit cast error 2024-01-16 17:57:31 +02:00
Techatrix 06410f58bd AstGen: properly handle ill-formed switch on error 2024-01-16 05:55:26 +01:00
Techatrix 8b9425c248 AstGen: add error message for capture error by ref in switch on error 2024-01-16 05:55:26 +01:00
Andrew Kelley 32e88251e4 update test case for new const/var compile error
commit 8afafa717f was created when this
error did not exist yet.
2024-01-15 01:53:41 -07:00
dweiller 8afafa717f sema: allow slicing *T with comptime known [0..1] 2024-01-14 17:26:45 -08:00
Andrew Kelley bd46410419 Revert "Merge pull request #18410 from dweiller/by-length-slice-bug"
This reverts commit d9d840a33a, reversing
changes made to a04d433094.

This is not an adequate implementation of the missing safety check, as
evidenced by the changes to std.json that are reverted in this commit.

Reopens #18382
Closes #18510
2024-01-13 23:21:44 -07:00
Meghan Denny 3d6c26525f sema: forbid asm output to const locals 2024-01-12 16:23:42 -08:00