Veikka Tuominen
3a8777a8bb
fix hyphenation in test case
...
Follow up to 51d9db856978610c24b3fed50a9550455a2eb64b
2022-10-12 16:10:57 +03:00
Andrew Kelley
7ce1ee1bce
Merge pull request #13081 from r00ster91/docs
...
fix(text): hyphenation and other fixes
2022-10-12 05:26:11 -04:00
Veikka Tuominen
b316c25cc6
Merge pull request #13075 from Vexu/stage2-fixes
...
Stage2 misc fixes
2022-10-10 23:27:17 +02:00
Veikka Tuominen
3ccd4907fb
Sema: add error for capturing a runtime value outside of function scope
...
Closes #13104
2022-10-08 16:58:54 +03:00
Veikka Tuominen
1500b9ddc3
Sema: restore sema.src after inline call
...
Closes #13099
2022-10-08 16:58:26 +03:00
Veikka Tuominen
4a6cc1c602
Sema: allow equality comparisons between error unions and error sets
...
Closes #1302
2022-10-07 11:04:02 +03:00
Veikka Tuominen
29ae6515f3
AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes
...
Closes #8532
2022-10-07 11:04:02 +03:00
Ali Chraghi
6672921e32
Sema: fix error location when casting pointer to slice
...
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-10-06 21:18:01 +03:00
Veikka Tuominen
dffce98045
Sema: disallow using stage1 fn ptrs in extern contexts
...
Closes #13022
2022-10-06 20:09:45 +03:00
Veikka Tuominen
775e055b59
Sema: generic function instantiation inherits parent's branch quota
...
Closes #12624
2022-10-06 20:09:45 +03:00
Veikka Tuominen
94039d66ed
Sema: disallow fieldParentPtr and offsetOf on comptime fields
...
Comptime fields are tied to the type and behave more like declarations
so these operations cannot return anything useful for them.
2022-10-06 20:09:45 +03:00
Veikka Tuominen
0b1dd845d9
stage2: add error for non-void error union payload being ignored
...
See https://github.com/ziglang/zig/pull/6060#discussion_r471032912
2022-10-06 15:39:06 +03:00
r00ster91
8e2aaf6aed
fix(text): hyphenate "runtime" adjectives
2022-10-05 21:33:42 +02:00
r00ster91
51d9db8569
fix(text): hyphenate "comptime" adjectives
2022-10-05 21:19:30 +02:00
r00ster91
654e0b6679
fix(text): hyphenation and other fixes
2022-10-05 21:19:10 +02:00
Veikka Tuominen
c0350cf87e
Sema: avoid passing undefined as reason to failWithNeededComptime
...
Closes #13046
2022-10-05 17:26:29 +03:00
Andrew Kelley
ff534d2267
Merge pull request #12979 from Vexu/inline-switch
...
Implement inline switch cases
2022-10-03 23:43:09 -04:00
Jacob Young
9d8cdb855b
Sema: fix function paramater count mismatch note
...
expected type 'fn() void', found 'fn(i32) void'
function with 0 parameters cannot cast into a function with 0 parameters
=>
expected type 'fn() void', found 'fn(i32) void'
function with 1 parameters cannot cast into a function with 0 parameters
2022-10-03 13:06:49 +03:00
Julian
32d755beb8
Sema: require reified packed struct fields to have zero alignment
2022-10-03 13:05:12 +03:00
Veikka Tuominen
b3c6d774d2
stage2: improve error message for missing member in file root struct
...
* the root struct decl name is fully qualified
this prevents error messages containing 'main.main'
* avoid declared here note when file struct is missing a member
It always points at the start of the file which might contain another
container misleading the user.
2022-09-30 00:09:24 +03:00
Igor Anić
9f6f460124
Sema: improve source location in errors
...
resolves #12793
2022-09-29 14:45:08 +03:00
Jacob G-W
0a064eae99
stage2: detect duplicate enum values
...
Closes #12805
2022-09-28 12:48:54 +03:00
InKryption
c75e8f3616
Sema: check that reified enum field values fits tag type.
2022-09-27 18:38:37 +03:00
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
kkHAIKE
ba5cbea0c3
Sema: fix segfault when union init with empty field
2022-09-27 13:23:51 +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