Veikka Tuominen
950a0e2405
Sema: implement inline else for errors enums and bools
2022-09-27 18:33:23 +03:00
Veikka Tuominen
0e77259f44
add inline switch union tag captures
2022-09-27 18:33:23 +03:00
Veikka Tuominen
cccc4c3827
AstGen: analyze inline switch cases
2022-09-27 18:05:08 +03:00
John Schmidt
6cc2b26163
sema: load the correct AST in addFieldErrNote
...
The enum we want to get the fields from might not be declared in the
same file as the block we are analyzing, so we should get the AST from
the decl's file instead.
Closes #12950 .
2022-09-25 10:28:48 +02:00
Veikka Tuominen
581df942e1
Sema: correct sentinel check on implicit cast from array ptr
...
Closes #12938
2022-09-23 17:39:06 +03:00
Veikka Tuominen
3de5c3b503
Sema: check for slices in packed and extern type validation
...
Closes #12930
2022-09-23 17:39:06 +03:00
kkHAIKE
4961044ce8
AstGen: store void to ptr result loc when there is no else branch
2022-09-21 20:21:02 +03:00
kkHAIKE
183127733c
AstGen: make loop body's ResultLoc .none
...
Fixes #12555
Fixes #12551
Fixes #12455
2022-09-21 20:20:05 +03:00
Jacob Young
14f4c73191
sema: fix typo
2022-09-21 11:29:20 +02:00
Veikka Tuominen
694fab4848
std: add return address parameter to panic fn
2022-09-20 19:05:00 -07:00
Veikka Tuominen
3e80aa9079
Sema: validate @alignOf type
2022-09-20 00:50:13 +03:00
Veikka Tuominen
541b3e3a31
Sema: check pointer qualifiers before implicit cast
...
Closes #12881
2022-09-20 00:50:13 +03:00
Veikka Tuominen
fb91483e48
Sema: do not use coerceCompatiblePtr for ptrCast
2022-09-19 18:34:53 +03:00
Jakub Konka
437ddcce7a
test-cases: remove removed "note: referenced here" note from the error
2022-09-17 23:38:40 +02:00
Veikka Tuominen
b2aedb0709
Merge pull request #12796 from Vexu/referenced-by-v2
...
stage2: add referenced by trace to compile errors attempt #2 (+ some fixes)
2022-09-16 23:49:00 +03:00
Andrew Kelley
8edd7219c0
Sema: improve source location after as_node is used
...
+2 more passing compile error tests
2022-09-16 14:47:17 -04:00
Andrew Kelley
9f4408d68b
organize some compile error tests
...
Many of these tests check for the incorrect behavior of stage1 whereas
self-hosted correctly does not emit an error, so they are simply
deleted.
The remaining number of test cases within the stage1/ subdirectory is
reduced from 143 to 103.
2022-09-15 14:40:45 -04:00
Veikka Tuominen
31daea74d2
stage2: implement referenced by trace for error messages
...
Closes #7668
Closes #12141
2022-09-15 00:50:18 +03:00
Veikka Tuominen
5e37da6ade
Sema: check_comptime_control_flow needs to check runtime_index
2022-09-15 00:50:18 +03:00
Veikka Tuominen
002260c274
Sema: copy runtime_index & friends when making child blocks
2022-09-15 00:48:47 +03:00
Veikka Tuominen
349d78a443
validate number literals in AstGen
2022-09-13 20:26:04 -04:00
Andrew Kelley
b2e94de358
add compile error test for pointless discards
2022-09-13 10:01:17 -07:00
Andrew Kelley
ebd082d3f6
remove pointless discards in test cases
2022-09-13 02:04:20 -07:00
Veikka Tuominen
e323cf1264
stage2: change how defers are stored in Zir
...
Storing defers this way has the benefits that the defer doesn't get
analyzed multiple times in AstGen, it takes up less space, and it
makes Sema aware of defers allowing for 'unreachable else prong'
error on error sets in generic code.
The disadvantage is that it is a bit more complex and errdefers with
payloads now emit a placeholder instruction (but those are rare).
Sema.zig before:
Total ZIR bytes: 3.7794370651245117MiB
Instructions: 238996 (2.051319122314453MiB)
String Table Bytes: 89.2802734375KiB
Extra Data Items: 430144 (1.640869140625MiB)
Sema.zig after:
Total ZIR bytes: 3.3344192504882812MiB
Instructions: 211829 (1.8181428909301758MiB)
String Table Bytes: 89.2802734375KiB
Extra Data Items: 374611 (1.4290275573730469MiB)
2022-09-12 01:52:44 -04:00
Jacob Young
5b9c5191ab
type: print comptime on fn type params
...
This avoids the following confusing error message:
error: expected type 'fn(i32, i32) void', found 'fn(i32, i32) void'
2022-09-10 01:55:52 +03:00
Veikka Tuominen
99826a2ba8
Sema: fix UAF in zirClosureGet
...
Previously if a decl failed its capture scope would be deallocated and
set to undefined which would then lead to invalid dereference in
`zirClosureGet`. To avoid this set the capture scope to a special
failed state and fail the current decl with dependency failure if
the failed state is encountered in `zirClosureGet`.
Closes #12433
Closes #12530
Closes #12593
2022-09-08 00:37:11 +03:00
Veikka Tuominen
0fa80e66b7
Sema: correct types in @memset and @memcpy
...
Closes #12750
2022-09-08 00:37:11 +03:00
Veikka Tuominen
b83c037f9f
Sema: only ABI sized packed structs are extern compatible
2022-09-03 01:04:46 +03:00
Veikka Tuominen
f281f3d10e
Sema: improve behavior of comptime_int backed enums
2022-09-02 17:57:11 +03:00
Veikka Tuominen
a9cdacff95
Sema: add error for enum tag value overflow
...
Closes #12291
2022-09-02 17:57:11 +03:00
Veikka Tuominen
7a51e0befe
Sema: fix noalias coercion error message
...
Closes #11769
2022-09-02 17:57:11 +03:00
Veikka Tuominen
1c4c68e6ba
AstGen: use reachableExpr for try operand
...
Closes #12248
2022-09-02 17:57:10 +03:00
Veikka Tuominen
2cd3989cb3
Sema: add more validation to coerceVarArgParam
...
Closes #12706
2022-09-01 13:16:33 +03:00
Veikka Tuominen
d3b4b2edf1
Sema: shift of comptime int with runtime value
...
Closes #12290
2022-08-30 12:22:07 -07:00
Veikka Tuominen
01d19a8d3c
Sema: do not emit generic poison for non generic parameters
...
Closes #12679
2022-08-30 12:22:07 -07:00
Veikka Tuominen
67a44211f7
Sema: improve handling of always_tail call modifier
...
Closes #4301
Closes #5692
Closes #6281
Closes #10786
Closes #11149
Closes #11776
2022-08-30 12:22:07 -07:00
Veikka Tuominen
a4b52ccd9f
Sema: fix access of inactive union field when enum and union fields are in different order
...
Closes #12667
2022-08-29 13:45:37 -07:00
Veikka Tuominen
6aead18ab3
add error tests for now correctly behaving cases
...
Closes #6377
2022-08-28 15:41:21 +03:00
Veikka Tuominen
1401890ed5
Sema: add error for switch on slice
...
Closes #12651
2022-08-28 15:41:21 +03:00
Veikka Tuominen
fc213e2d61
AstGen: add error for named function type
...
Closes #12660
2022-08-28 15:41:21 +03:00
antlilja
ae8d26a6a0
Sema: add error for non-comptime param in comptime func
...
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.
Co-authored-by: Veikka Tuominen <git@vexu.eu >
2022-08-27 11:17:48 +03:00
Veikka Tuominen
4405188cf7
Sema: ignore comptime params in partial func type check
...
This fixes a bug exposed by cd1833044a
where a function type would be converted to generic_poison even after
being instantiated due to containing comptime only types.
This could also be fixed by just checking `is_generic_instantiation`
but this way also provides better type names.
Closes #12625
2022-08-25 16:29:23 +03:00
Andrew Kelley
7a881435ed
Merge pull request #12623 from Vexu/stage2-fixes
...
Stage2 fixes
2022-08-24 15:59:46 -04:00
Andrew Kelley
2a96209c40
Merge pull request #12574 from Vexu/remove-bit-op-type-param
...
stage2+stage1: remove type parameter from bit builtins
2022-08-24 15:57:44 -04:00
Veikka Tuominen
69a3c4e279
Sema: correctly reset inst_map for analyzeInlineCallArg
...
Closes #12622
2022-08-24 21:31:02 +03:00
Veikka Tuominen
1d0b729f28
Sema: fix crash on slice of non-array type
...
Closes #12621
2022-08-24 21:31:02 +03:00
Veikka Tuominen
cd1833044a
Sema: do not construct nested partial function types
...
Closes #12616
2022-08-24 21:31:02 +03:00
Veikka Tuominen
5404dcdfd8
Sema: fix fieldCallBind on tuples and anon structs
...
Closes #12573
2022-08-22 14:31:58 +03:00
Veikka Tuominen
62ff8871ed
stage2+stage1: remove type parameter from bit builtins
...
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Veikka Tuominen
b55a5007fa
Sema: fix parameter of type 'T' must be comptime error
...
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00