aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
AgeCommit message (Collapse)Author
2022-08-22Sema: check for astgen failures in `semaStructFields`Veikka Tuominen
The struct might be a top level struct in which case it might not have Zir. Closes #12548
2022-08-21Sema: add note about function call being comptime because of comptime only ↵Veikka Tuominen
return type
2022-07-25Sema: `analyzeInlineCallArg` needs a block for the arg and the paramVeikka Tuominen
2022-07-15Compilation: point caret in error message at the main tokenVeikka Tuominen
2022-07-12Compilation: indent multiline error messages properlyr00ster91
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-04-28test: migrate stage1 compile error tests to updated test manifestJakub Konka
2022-03-31test harness improvementsAndrew Kelley
* `-Dskip-compile-errors` is removed; `-Dskip-stage1` is added. * Use `std.testing.allocator` instead of a new instance of GPA. - Fix the memory leaks this revealed. * Show the file name when it is not parsed correctly such as when the manifest is missing. - Better error messages when test files are not parsed correctly. * Ignore unknown files such as swap files. * Move logic from declarative file to the test harness implementation. * Move stage1 tests to stage2 tests where appropriate.
2022-03-30stage2: test compile errors independentlyAndrew Kelley
Until we land some incremental compilation bug fixes, this prevents CI failures when running the compile errors test cases.
2022-03-29test harness: include case names for compile errorsAndrew Kelley
in the progress nodes
2022-03-25Move existing compile errors to independent filesCody Tapscott
Some cases had to stay behind, either because they required complex case configuration that we don't support in independent files yet, or because they have associated comments which we don't want to lose track of. To make sure I didn't drop any tests in the process, I logged all obj/test/exe test cases from a run of "zig build test" and compared before/after this change. All of the test cases match, with two exceptions: - "use of comptime-known undefined function value" was deleted, since it was a duplicate - "slice sentinel mismatch" was renamed to "vector index out of bounds", since it was incorrectly named
2022-03-25Add rudimentary compile error test file supportCody Tapscott
This brings two quality-of-life improvements for folks working on compile error test cases: - test cases can be added/changed without re-building Zig - wrapping the source in a multi-line string literal is not necessary I decided to keep things as simple as possible for this initial implementation. The test "manifest" is a contiguous comment block at the end of the test file: 1. The first line is the test case name 2. The second line is a blank comment 2. The following lines are expected errors Here's an example: ```zig const U = union(enum(u2)) { A: u8, B: u8, C: u8, D: u8, E: u8, }; export fn entry() void { _ = U{ .E = 1 }; } // union with too small explicit unsigned tag type // // tmp.zig:1:22: error: specified integer tag type cannot represent every field // tmp.zig:1:22: note: type u2 cannot fit values in range 0...4 ``` The mode of the test (obj/exe/test), as well as the target (stage1/stage2) is determined based on the directory containing the test. We'll probably eventually want to support embedding this information in the test files themselves, similar to the arocc test runner, but that enhancement can be tackled later.
2022-03-23stage2: able to slice to sentinel index at comptimeMitchell Hashimoto
The runtime behavior allowed this in both stage1 and stage2, but stage1 fails with index out of bounds during comptime. This behavior makes sense to support, and comptime behavior should match runtime behavior. I implement this fix only in stage2.
2022-03-21stage2: out of bounds error for slicingMitchell Hashimoto
2022-03-20add error when binary ops don't have matching whitespace on both sidesDaniel Hooper
This change also moves the warning about "&&" from the AstGen into the parser so that the "&&" warning can supersede the whitespace warning.
2022-03-19stage1: make type names more uniqueRobin Voetter
2022-03-16stage2: move duplicate error set check to AstGenMitchell Hashimoto
2022-03-08deprecated TypeInfo in favor of TypeJonathan Marler
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-02-23stage1: rename TypeInfo.FnArg to Fn.ParamVeikka Tuominen
2022-02-19parser: fix "previous field here" pointing to wrong fieldVeikka Tuominen
2022-02-17parser: add notes to decl_between_fields errorVeikka Tuominen
2022-02-17parser: add error for missing colon before continue exprVeikka Tuominen
If a '(' is found where the continue expression was expected and it is on the same line as the previous token issue an error about missing colon before the continue expression.
2022-02-17stage1: improve error message when casting tuplesVeikka Tuominen
2022-02-17parser: make some errors point to end of previous tokenVeikka Tuominen
For some errors if the found token is not on the same line as the previous token, point to the end of the previous token. This usually results in more helpful errors.
2022-02-13update compile error testsVeikka Tuominen
2022-02-09stage 1: improve error message if error union is cast to payload (#10770)Sebsatian Keller
Also: Added special error message for for `?T` to `T` casting
2022-02-01stage2: remove anytype fields from the languageAndrew Kelley
closes #10705
2022-02-01stage1: avoid anytype fields for type infoAndrew Kelley
prerequisite for #10705
2022-01-31update behavior tests and compile error testsAndrew Kelley
2022-01-20stage1: remove the "referenced here" error noteAndrew Kelley
It's generally noise. The parts where it is useful will need to be redone to not be annoying for the general case.
2021-12-27AstGen: fix loop result locationsAndrew Kelley
The main problem was that the loop body was treated as an expression that was one of the peer result values of a loop, when in reality the loop body is noreturn and only the `break` operands are the result values of loops. This was solved by introducing an override that prevents rvalue() from emitting a store to result location instruction for loop bodies. An orthogonal change also included in this commit is switching `elem_val` index expressions to using `coerced_ty` and doing the coercion to `usize` inside `Sema`, resulting in smaller ZIR (since the cast becomes implied). I also changed the break operand expression to use `reachableExpr`, introducing a new compile error for double break. This makes a few more behavior tests pass for `while` and `for` loops.
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-12-08stage1: fix regression of shift by negative value errorAndrew Kelley
The previous commit (38b2d6209239f0dad7cb38e656d9d38506f126ca) regressed the compile error test case for when doing saturating shift left of a comptime-known negative RHS. This commit additionally fixes the error for regular shifts in addition to saturating shifts.
2021-12-02parse.zig: make chained comparison operators a parse errorMatthew Borkowski
2021-11-30allocgate: fix failing testsLee Cannon
2021-11-30allocgate: stage 1 and 2 buildingLee Cannon
2021-11-29AstGen: require binary operations to have reachable operandsAndrew Kelley
2021-11-27stage2: implement `@typeName`Andrew Kelley
* stage1: change the `@typeName` of `@TypeOf(undefined)`, `@TypeOf(null)`, and `@TypeOf(.foo)` to match stage2. * move passing behavior tests to the passing-for-stage2 section.
2021-11-25stage1: fix exporting enumsAndrew Kelley
After extern enums were removed, stage1 was left in an incorrect state of checking for `extern enum` for exported enums. This commit fixes it to look for an explicit integer tag type instead, and adds test coverage for the compile error case as well as the success case. closes #9498
2021-11-24stage2: fix cleanup code for `@import` errorsAndrew Kelley
When adding test coverage, I noticed an inconsistency in which source location the compile error was pointing to for `@embedFile` errors vs `@import` errors. They now both point to the same place, the string operand. closes #9404 closes #9939
2021-11-24stage2: add test coverage for `@embedFile` outside package pathAndrew Kelley
closes #6662
2021-11-24AstGen: use reachableExpr for return operandAndrew Kelley
Related: #9630
2021-11-22stage1: improve packed struct array padding error messageKirk Scheibelhut
2021-10-15Sat shl neg rhs (#9949)travisstaloch
* saturating shl - check for negative rhs at comptime - adds expected compile_errors case for negative rhs * add expected compile error for sat shl assign
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-09-28saturating arithmetic supports integers onlyAndrew Kelley
2021-09-24Spelling corrections (#9833)Josh Soref
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-09-20Address Spaces: Yeet address space on function prototypesRobin Voetter
This is a property which solely belongs to pointers to functions, not to the functions themselves. This cannot be properly represented by stage 2 at the moment, as type with zigTypeTag() == .Fn is overloaded for for function pointers and function prototypes.
2021-09-20Address Spaces: Adapt compile error test cases to @Type with address spacesRobin Voetter
2021-09-20Address Spaces: Pointer and function info in @TypeRobin Voetter
2021-09-01std.os fixes to get the test suite passing againAndrew Kelley