314 Commits

Author SHA1 Message Date
Jacob Young
a1ed4bd796 cbe: fix remaining aarch64 issues 2023-04-21 16:36:31 -04:00
mlugg
d5f1a8823e Sema: allow ptr field access on pointer-to-array
Also remove an incorrect piece of logic which allowed fetching the 'len'
property on non-single-ptrs (e.g. many-ptrs) and add a corresponding
compile error test case.

Resolves: #4765
2023-04-20 09:05:22 -07:00
mlugg
ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Veikka Tuominen
66520c8342 Sema: validate array element types
Fixes the compiler crash part of #15175
2023-04-05 14:45:56 +03:00
Veikka Tuominen
4a5628e730 Module: fix lazy srcloc resolution for new for loop syntax
Closes #15081
2023-03-26 15:14:03 +03:00
Veikka Tuominen
87e07d8671 fix broken test cases exposed by ec445fb6b8bb3f3d423cafa4f3a7860da65ca233
shoulda rebased
2023-03-21 20:57:14 +02:00
John Schmidt
ec445fb6b8 Improve error messages for break type coercion 2023-03-21 15:09:42 +02:00
Veikka Tuominen
f7204c7f37
Merge pull request #15028 from Vexu/compile-errors
Sema: improve error message of field access of wrapped type
2023-03-21 14:55:36 +02:00
mlugg
3a25f6a22e Port some stage1 test cases to stage2
There are now very few stage1 cases remaining:
* `cases/compile_errors/stage1/obj/*` currently don't work correctly on
  stage2. There are 6 of these, and most of them are probably fairly
  simple to fix.
* `cases/compile_errors/async/*` and all remaining `safety/*` depend on
  async; see #6025.

Resolves: #14849
2023-03-20 19:55:50 -04:00
Veikka Tuominen
82133cd992 Sema: improve error message of field access of wrapped type
Closes #15027
2023-03-21 00:34:12 +02:00
InKryption
9964f1c160 Add error for bad cast from *T to *[n]T
Casting `*T` to `*[1]T` should still work, but every other length
will now be a compiler error instead of a potential OOB access.
2023-03-16 13:00:36 +02:00
Andrew Kelley
7177b39946 fix test-case copy-paste typo from earlier commit
commit 3204d00a5e7fe119b690e921138a439fb84dff5b intended to move this
passing test case from stage1 folder but it was accidentally changed to
have identical contents as a different test case instead.

Fortunately, the test case has not regressed, so I simply replaced it
with the intended test from before.
2023-03-15 12:32:17 -07:00
Andrew Kelley
21b544a90a fix compile log test case expected output 2023-03-15 10:48:15 -07:00
Andrew Kelley
6664d2418d test-cases: add missing compile log output
The new testing harness is not bound by previous limitations; it can now
test compile log output as well.
2023-03-15 10:48:15 -07:00
Andrew Kelley
29cfd47d65 re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.

For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.

The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.

Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.

link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.

The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-15 10:48:14 -07:00
mlugg
948926c513 Sema: improve error message when calling non-member function as method
Resolves: #14880
2023-03-12 18:47:02 +02:00
mlugg
023753b469 Sema: correctly detect use of undefined within slices in @Type
Resolves: #14712
2023-03-10 12:18:06 +02:00
mlugg
14590e956e Fix test case added in 6d7fb8f 2023-03-09 23:25:38 +02:00
mlugg
6d7fb8f19c Sema: check type of comptime try operand
Resolves: #14693
2023-03-09 02:02:19 +02:00
John Schmidt
ecc0108cea astgen: fill result location with void value if no other value
With this change, `break` and `break :blk` will fill the result location
with `.void_value`, ensuring that the value will be type checked.
The same will happen for a for loop that contains no `break`s in it's body.

Closes https://github.com/ziglang/zig/issues/14686.
2023-03-08 16:35:53 +02:00
r00ster91
010596c930 AstGen: compile-error on primitive value export
Fixes #14778

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-04 22:52:57 +02:00
John Schmidt
e41bc640c6 astgen: do not discard result location in for/while loops
If we use the discard result location any break with a value will be
ignored and not checked for usage.

Closes https://github.com/ziglang/zig/issues/14684.
2023-03-01 02:51:59 -05:00
Isaac Freund
05da5b32a8 Sema: implement @fieldParentPtr for unions 2023-02-21 15:57:13 +02:00
Andrew Kelley
53104b9165 add test coverage for fixed bug. closes #5410 2023-02-19 21:18:27 -07:00
Veikka Tuominen
f10950526e implement writeToMemory/readFromMemory for pointers 2023-02-19 13:54:52 -05:00
Andrew Kelley
8b05205bb7 implement error for unbounded for loops 2023-02-18 19:20:19 -07:00
Andrew Kelley
4dd958d585 improve error message for byref capture of byval array 2023-02-18 19:20:19 -07:00
Andrew Kelley
601db3981c fix source location for not-indexable for loop errors 2023-02-18 19:20:19 -07:00
Andrew Kelley
bcb72401d3 AstGen: add error for discard of unbounded counter 2023-02-18 19:17:21 -07:00
Andrew Kelley
22965e6fcb Sema: improve error message for mismatched for loop lengths 2023-02-18 19:17:21 -07:00
Andrew Kelley
8c96d0dddd update test-cases for new for loop syntax 2023-02-18 19:17:21 -07:00
Veikka Tuominen
7199d7c777 split @qualCast into @constCast and @volatileCast 2023-02-15 01:43:57 +02:00
Veikka Tuominen
b9c2837c1c Sema: validate inferred error set payload type
This was missed in b0a55e1b3be3a274546f9c18016e9609d546bdb0
2023-02-11 14:36:54 +02:00
Andrew Kelley
6b7ad22981
Merge pull request #14477 from Vexu/fixes
Improve `@ptrCast` errors, fix some bugs
2023-02-01 23:31:52 -05:00
Veikka Tuominen
490addde27 Sema: fix error location on comptime arg to typed generic param
Closes #14505
2023-02-01 20:50:43 +02:00
Andrew Kelley
34b3145099 update test case for new std.builtin.OptimizeMode API 2023-01-31 15:09:35 -07:00
r00ster91
17404f8e6e Sema: emit compile error for comptime or inline call of function pointer 2023-01-31 17:15:34 +02:00
Veikka Tuominen
f16c10a86b implement @qualCast 2023-01-30 18:55:57 +02:00
Veikka Tuominen
fe4ea31f7e Sema: replace backticks with single quotes
Most error messages already use single quotes for everything
so this makes the remaining ones consistent.
2023-01-30 15:20:16 +02:00
Veikka Tuominen
a9785fe8ee Sema: add helpful notes to invalid @ptrCast operations
Closes #14474
2023-01-30 15:20:16 +02:00
Veikka Tuominen
b129350cb5 AstGen: fix crash on invalid decltest
Closes  #14476
2023-01-30 15:20:16 +02:00
Veikka Tuominen
720d82721f Sema: ensure args to inline comptime args are comptime-known
Closes #14413
2023-01-30 15:20:16 +02:00
Veikka Tuominen
1f475de852 Sema: fix unwrapping null when reporting error on member access
Closes #14399
2023-01-22 01:04:20 +02:00
Veikka Tuominen
94be9dcc7f enable passing compile error test 2023-01-17 20:28:43 +02:00
Veikka Tuominen
1658e4893d AstGen: add note pointing to tuple field
Closes #14188
2023-01-11 21:11:21 +02:00
Veikka Tuominen
8b1780d939 Sema: fix condition for omitting comptime arg from function type
Closes #14164
2023-01-11 21:11:21 +02:00
Veikka Tuominen
f2faa303a5 Sema: handle enum expressions referencing local variables
Closes #12272
2023-01-05 22:03:32 +02:00
Veikka Tuominen
8c4727f9ab Sema: remove generic function from monomorphed_funcs on any error 2023-01-05 14:26:53 +02:00
Veikka Tuominen
3e084d8de3 Sema: only untyped undefined should coerce to all types
Closes #13958
2023-01-05 14:26:53 +02:00
Veikka Tuominen
352c71873b Sema: improve struct/union field error locations
Closes #14206
2023-01-05 13:11:36 +02:00