Commit Graph

717 Commits

Author SHA1 Message Date
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
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
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
Bogdan Romanyuk 4a1a5ee47b AstGen: add error for redundant comptime var in comptime scope (#18242) 2024-01-09 20:09:39 -05:00
dweiller 69ab687156 test: add tests for switch_block_err_union 2024-01-09 14:42:12 +11:00
Veikka Tuominen 804cee3b93 categorize behavior/bugs/<issueno>.zig tests 2024-01-06 16:49:41 -08:00
Carl Åstholm 501a2350ab sema: Prevent reifying non-empty union with empty tag type 2024-01-04 22:38:31 +02:00
dweiller 1748511058 sema: add compile error for OOB by-length slice of array 2023-12-31 15:36:58 +11:00
Andrew Kelley 3d23ba9c35 Revert "Sema: forbid @breakpoint from being called at comptime"
This reverts commit f88b523065.

Let's please go through the language proposal process for this change. I
don't see any justification for this breaking change even in the commit
message.
2023-12-11 12:24:15 -07:00
Bogdan Romanyuk f88b523065 Sema: forbid @breakpoint from being called at comptime 2023-12-11 17:52:19 +02:00
Veikka Tuominen 69195d0cd4 AstGen: add error for using inline loops in comptime only scopes 2023-12-08 16:54:32 -08:00
Veikka Tuominen 39a966b0a4 Sema: improve error location for array cat/mul 2023-11-30 13:15:40 +02:00
Bogdan Romanyuk 2252dcc508 Compiler: move checking function-scope-only builtins to AstGen 2023-11-25 17:29:07 +00:00
Bogdan Romanyuk aa31096cbd Sema: disallow call to undefined function 2023-11-23 02:08:15 +00:00
Andrew Kelley d5e21a4f1a std: remove meta.trait
In general, I don't like the idea of std.meta.trait, and so I am
providing some guidance by deleting the entire namespace from the
standard library and compiler codebase.

My main criticism is that it's overcomplicated machinery that bloats
compile times and is ultimately unnecessary given the existence of Zig's
strong type system and reference traces.

Users who want this can create a third party package that provides this
functionality.

closes #18051
2023-11-22 13:24:27 -05:00
Andrew Kelley 54d196bb30 Merge pull request #18057 from Vexu/fixes
Fix bad error location on field init with field access
2023-11-21 15:12:03 -05:00
Veikka Tuominen a947f97331 Sema: fix bad error location on field init with field access
Closes #14753
2023-11-21 13:59:14 +02:00
Bogdan Romanyuk 583afd6f0c value: update isDeclRef for anonymous declarations 2023-11-21 13:21:32 +02:00
mlugg 38b373bf0b cases: add compile error test for never-mutated local variable 2023-11-19 11:11:50 +00:00
mlugg 21fa187abc test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
dweiller 325e0f5f0e test: check compile errors when compilation has no errors 2023-11-19 00:12:43 +02:00
Curtis Tate Wilkinson 7b99189f19 Add struct declaration location to empty root struct field member error 2023-11-18 12:03:10 +00:00
David 941090d94f Move duplicate field detection for struct init expressions into AstGen
Partially addresses #17916.
2023-11-16 14:38:16 +00:00
Krzysztof Wolicki acf9de376d Sema: Add error for non-power of 2 field alignment when reifying Unions, Structs, Pointers 2023-11-16 10:19:54 +02:00
Andrew Kelley 70d8baaec1 Revert "Sema: fix comparison with undefined"
This reverts commit 547481c31c.

There is a comment that did not get addressed with this patch, and the
required test cases are not added.

Reopens #17798.
2023-11-12 14:33:17 -07:00
Bogdan Romanyuk 547481c31c Sema: fix comparison with undefined 2023-11-12 11:03:23 +02:00
Bogdan Romanyuk ec934c6d32 disallow calling @trap at comptime 2023-11-10 18:39:42 +02:00
mlugg 3f10b3ee1e Sema: do not allow comptime-only pointer fields in packed structs 2023-11-10 06:51:48 +00:00
mlugg 4504e03a18 Sema: fix source location for untyped array init with result type
Resolves: #17923
2023-11-08 06:56:52 +00:00