aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2025-01-13Sema: disallow non scalar sentinels in array types and reified types (#22473)xdBronch
2025-01-12Dwarf: emit debug info for extern globalsJacob Young
2025-01-12behavior: referencing an extern means depending on itAndrew Kelley
2025-01-13Sema: allow tail calls of function pointersmlugg
Resolves: #22474
2025-01-11compiler: improve "... contains reference to comptime var" errorsmlugg
`Sema.explainWhyValueContainsReferenceToComptimeVar` (concise name!) adds notes to an error explaining how to get from a given `Value` to a pointer to some `comptime var` (or a comptime field). Previously, this error could be very opaque in any case where it wasn't obvious where the comptime var pointer came from; particularly for type captures. Now, the error notes explain this to the user.
2025-01-10cbe: fix miscomps of the compilerJacob Young
2025-01-09Sema: rewrite semantic analysis of function callsmlugg
This rewrite improves some error messages, hugely simplifies the logic, and fixes several bugs. One of these bugs is technically a new rule which Andrew and I agreed on: if a parameter has a comptime-only type but is not declared `comptime`, then the corresponding call argument should not be *evaluated* at comptime; only resolved. Implementing this required changing how function types work a little, which in turn required allowing a new kind of function coercion for some generic use cases: function coercions are now allowed to implicitly *remove* `comptime` annotations from parameters with comptime-only types. This is okay because removing the annotation affects only the call site. Resolves: #22262
2025-01-08cbe: fix miscomps of x86_64 backendJacob Young
2025-01-07test: Enable long calls for all thumb/thumbeb module tests.Alex Rønne Petersen
The relocation range issues will happen eventually as we add more code to the standard library and test suites, so we may as well just deal with this now. @MasonRemaley ran into this in #20271, for example.
2025-01-06test: Disable `align(N) on functions` and `@alignCast functions` for thumbeb ↵Alex Rønne Petersen
too.
2025-01-06test: Disable vector behavior tests affected by #22060 for thumbeb too.Alex Rønne Petersen
2025-01-05x86_64: fix `@errorName` dataJacob Young
The final offset was clobbering the first error name, which is revealed by an out of bounds when the global error set is empty. Closes #22362
2025-01-05Dwarf: implement new incremental line number update APIJacob Young
2025-01-04incremental: add new test casesmlugg
These cover the fixes from the last few commits.
2025-01-03Zir: split up start and end of range in `for_len`mlugg
The old lowering was kind of neat, but it unintentionally allowed the syntax `for (123) |_| { ... }`, and there wasn't really a way to fix that. So, instead, we include both the start and the end of the range in the `for_len` instruction (each operand to `for` now has *two* entries in this multi-op instruction). This slightly increases the size of ZIR for loops of predominantly indexables, but the difference is small enough that it's not worth complicating ZIR to try and fix it.
2025-01-02Sema: correctly label `block_comptime` for restoring error return trace indexmlugg
Resolves: #22384
2025-01-01Merge pull request #22379 from mlugg/incremental-fixesMatthew Lugg
incremental: bugfixes
2025-01-01Sema: fix invalid coercion `*[n:x]T` -> `*[m]T` for `n != m`mlugg
The change in `Sema.coerceExtra` is just to avoid an unhelpful error message, covered by the added test case. Resolves: #22373
2025-01-01incremental: fix errors not being deleted upon re-analysismlugg
Previously, logic in `Compilation.getAllErrorsAlloc` was corrupting the `failed_analysis` hashmap. This meant that on updates after the initial update, attempts to remove entries from this map (because the `AnalUnit` in question is being re-analyzed) silently failed. This resulted in compile errors from earlier updates wrongly getting "stuck", i.e. never being removed. This commit also adds a few log calls which helped me to find this bug.
2024-12-31cases: update to new compile error wordingsmlugg
2024-12-31cases: add cases for runtime code in comptime scopesmlugg
2024-12-29Merge pull request #22344 from Techatrix/slice-of-sliceAndrew Kelley
fix incorrect slicing by length detection cases
2024-12-29add `@Type` behavior tests from #19985Travis Staloch
2024-12-29Value: implement `orderAgainstZeroInner` for errorsDavid Rubin
2024-12-29fix slice of slice with sentinel on the lhs sliceTechatrix
example: ```zig test { var foo: [2:0]u8 = .{ 1, 2 }; _ = foo[0.. :1][0..2]; } ``` A `.slice_open` ast node will not have a end index nor sentinel.
2024-12-29fix slice of slice with sentinel but no end indexTechatrix
example: ```zig test { var foo = ""; _ = foo[0..][0.. :0]; } ``` A `.slice_sentinel` ast node may not have an end index.
2024-12-28AstGen: lower function addrspace expression correctlymlugg
Also, add some basic behavior tests for addrspace and linksection which would have caught this bug in CI.
2024-12-24compiler: analyze type and value of global declaration separatelymlugg
This commit separates semantic analysis of the annotated type vs value of a global declaration, therefore allowing recursive and mutually recursive values to be declared. Every `Nav` which undergoes analysis now has *two* corresponding `AnalUnit`s: `.{ .nav_val = n }` and `.{ .nav_ty = n }`. The `nav_val` unit is responsible for *fully resolving* the `Nav`: determining its value, linksection, addrspace, etc. The `nav_ty` unit, on the other hand, resolves only the information necessary to construct a *pointer* to the `Nav`: its type, addrspace, etc. (It does also analyze its linksection, but that could be moved to `nav_val` I think; it doesn't make any difference). Analyzing a `nav_ty` for a declaration with no type annotation will just mark a dependency on the `nav_val`, analyze it, and finish. Conversely, analyzing a `nav_val` for a declaration *with* a type annotation will first mark a dependency on the `nav_ty` and analyze it, using this as the result type when evaluating the value body. The `nav_val` and `nav_ty` units always have references to one another: so, if a `Nav`'s type is referenced, its value implicitly is too, and vice versa. However, these dependencies are trivial, so, to save memory, are only known implicitly by logic in `resolveReferences`. In general, analyzing ZIR `decl_val` will only analyze `nav_ty` of the corresponding `Nav`. There are two exceptions to this. If the declaration is an `extern` declaration, then we immediately ensure the `Nav` value is resolved (which doesn't actually require any more analysis, since such a declaration has no value body anyway). Additionally, if the resolved type has type tag `.@"fn"`, we again immediately resolve the `Nav` value. The latter restriction is in place for two reasons: * Functions are special, in that their externs are allowed to trivially alias; i.e. with a declaration `extern fn foo(...)`, you can write `const bar = foo;`. This is not allowed for non-function externs, and it means that function types are the only place where it is possible for a declaration `Nav` to have a `.@"extern"` value without actually being declared `extern`. We need to identify this situation immediately so that the `decl_ref` can create a pointer to the *real* extern `Nav`, not this alias. * In certain situations, such as taking a pointer to a `Nav`, Sema needs to queue analysis of a runtime function if the value is a function. To do this, the function value needs to be known, so we need to resolve the value immediately upon `&foo` where `foo` is a function. This restriction is simple to codify into the eventual language specification, and doesn't limit the utility of this feature in practice. A consequence of this commit is that codegen and linking logic needs to be more careful when looking at `Nav`s. In general: * When `updateNav` or `updateFunc` is called, it is safe to assume that the `Nav` being updated (the owner `Nav` for `updateFunc`) is fully resolved. * Any `Nav` whose value is/will be an `@"extern"` or a function is fully resolved; see `Nav.getExtern` for a helper for a common case here. * Any other `Nav` may only have its type resolved. This didn't seem to be too tricky to satisfy in any of the existing codegen/linker backends. Resolves: #131
2024-12-23Zir: refactor `declaration` instruction representationmlugg
The new representation is often more compact. It is also more straightforward to understand: for instance, `extern` is represented on the `declaration` instruction itself rather than using a special instruction. The same applies to `var`, making both of these far more compact. This commit also separates the type and value bodies of a `declaration` instruction. This is a prerequisite for #131. In general, `declaration` now directly encodes details of the syntax form used, and the embedded ZIR bodies are for actual expressions. The only exception to this is functions, where ZIR is effectively designed as if we had #1717. `extern fn` declarations are modeled as `extern const` with a function type, and normal `fn` definitions are modeled as `const` with a `func{,_fancy,_inferred}` instruction. This may change in the future, but improving on this was out of scope for this commit.
2024-12-19compiler: disallow `align` etc annotations on comptime-only globalsmlugg
This includes function aliases, but not function declarations. Also, re-introduce a target check for function alignment which was inadvertently removed in the prior commit.
2024-12-18compiler: disallow `callconv` etc from depending on function parametersmlugg
Resolves: #22261
2024-12-18test-standalone: migrate from deprecated std.Build APIsmlugg
2024-12-18test-link: migrate from deprecated std.Build APIsmlugg
2024-12-18test-debugger: migrate from deprecated std.Build APIsmlugg
2024-12-18test-run-translated-c: migrate from deprecated std.Build APIsmlugg
2024-12-18test-compare-output: migrate from deprecated std.Build APIsmlugg
2024-12-18test-stack-traces: migrate from deprecated std.Build APIsmlugg
2024-12-18test-cases: migrate from deprecated std.Build APIsmlugg
2024-12-18tests.zig: migrate from deprecated std.Build APIsmlugg
2024-12-18std.Build.Step.Compile.Options: change `root_module` field type to `*Module`mlugg
2024-12-18std.Build.Step.Compile: change `root_module` field type to `*Module`mlugg
This commit changes the `root_module` field of `std.Build.Step.Compile` to be a `*Module` rather than a `Module`. This is a breaking change, but an incredibly minor one (the full potential extent of the breakage can be seen in the modified standalone test). This change will be necessary for an upcoming improvement, so it was convenient to make it here.
2024-12-18std.Build: remove deprecated APIsEric Joldasov
These APIs were all deprecated prior to the release of 0.13.0, so can be safety removed in the current release cycle. `std.Build`: * `host` -> `graph.host` `std.Build.Step.Compile`: * `setLinkerScriptPath` -> `setLinkerScript` * `defineCMacro` -> `root_module.addCMacro` * `linkFrameworkNeeded`-> `root_module.linkFramework` * `linkFrameworkWeak`-> `root_module.linkFramework` `std.Build.Step.ObjCopy`: * `getOutputSource` -> `getOutput` `std.Build.Step.Options`: * `addOptionArtifact` -> `addOptionPath` * `getSource` -> `getOutput` `std.Build.Step.Run`: * `extra_file_dependencies` -> `addFileInput` * `addDirectorySourceArg` -> `addDirectoryArg` * `addPrefixedDirectorySourceArg` -> `addPrefixedDirectoryArg`
2024-12-16Sema: disallow unsafe in-memory coercionsmlugg
The error messages here aren't amazing yet, but this is an improvement on status quo, because the current behavior allows false negative compile errors, so effectively miscompiles. Resolves: #15874
2024-12-15Sema: disallow runtime stores to pointers with comptime-only element typesmlugg
2024-12-15Merge pull request #22219 from alexrp/arm-big-endianAlex Rønne Petersen
Add `armeb-linux-*`, `thumbeb-linux-*`, and `aarch64_be-linux-*` to CI
2024-12-14Move fetch-them-macos-headers tools to ziglang/zig.Alex Rønne Petersen
2024-12-14ensure `InstMap` capacity before remapping error codeDavid Rubin
2024-12-13Add compiler internals testsCarl Åstholm
There are several test decls inside `/src` that are not currently being tested and have bitrotted as a result. This commit revives those tests and adds the `test-compiler-internals` set of tests which tests everything reachable from `/src/main.zig`.
2024-12-13test: Add aarch64_be-linux-* to the module test matrix.Alex Rønne Petersen
2024-12-13test: Add thumbeb-linux-* to the module test matrix.Alex Rønne Petersen