aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
AgeCommit message (Collapse)Author
4 dayscompiler: fix most compilation errors from std.fs changesAndrew Kelley
4 daysupdate lockStderrWriter sitesAndrew Kelley
use the application's Io implementation where possible. This correctly makes writing to stderr cancelable, fallible, and participate in the application's event loop. It also removes one more hard-coded dependency on a secondary Io implementation.
6 dayscompiler: replace thread pool with `std.Io`Matthew Lugg
Eliminate the `std.Thread.Pool` used in the compiler for concurrency and asynchrony, in favour of the new `std.Io.async` and `std.Io.concurrent` primitives. This removes the last usage of `std.Thread.Pool` in the Zig repository.
6 dayscompiler,std: remove a handful of redundant discardsMatthew Lugg
I'm embarrassed to say I didn't realise until a few days ago that you could omit the `_` capture for `if`/`while` on `E!void`...
7 daysSema: fix nested error union coercionsMatthew Lugg
Previously, `E1!void` failed to coerce to `E2!E1!void` because it tried to coerce the `E1` error to an `E2` if comptime-known and refused to attempt any other coercion. This is a strange language rule with no clear justification, and breaks real use cases (such as calling `getOne` on an `Io.Queue(E!T)`). Instead, only error *sets* should try to coerce to an "error" value of an error union type.
2025-12-08sema: remove special case check in `is_non_err`pentuppup
2025-12-07sema: fix error_return_trace_index handling in zirCondBrPavel Verigo
2025-12-06detect `comptime var` references in asm input/output and improve errorspentuppup
2025-11-29Sema: initialize OPV comptime allocs correctlyMatthew Lugg
This was caused a `[0]std.builtin.Type.StructField.Attributes` to be considered `undefined`, even though that type is OPV so should prefer its OPV `.{}` over `undefined`. Resolves: #30039
2025-11-24frontend: introduce error.CanceledAndrew Kelley
2025-11-22all: replace all `@Type` usagesAli Cheraghi
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22compiler: replace `@Type` with individual type-creating builtinsMatthew Lugg
The new builtins are: * `@EnumLiteral` * `@Int` * `@Fn` * `@Pointer` * `@Tuple` * `@Enum` * `@Union` * `@Struct` Their usage is documented in the language reference. There is no `@Array` because arrays can be created like this: if (sentinel) |s| [n:s]T else [n]T There is also no `@Float`. Instead, `std.meta.Float` can serve this use case if necessary. There is no `@ErrorSet` and intentionally no way to achieve this. Likewise, there is intentionally no way to reify tuples with comptime fields, or function types with comptime parameters. These decisions simplify the Zig language specification, and moreover make Zig code more readable by discouraging overly complex metaprogramming. Co-authored-by: Ali Cheraghi <alichraghi@proton.me> Resolves: #10710
2025-11-20update deprecated ArrayListUnmanaged usage (#25958)Benjamin Jurk
2025-11-17sema: fix UAF in type mismatch errorxdBronch
2025-11-16sema: improve codegen of for loop safety checksxdBronch
2025-11-16Dedupe types when printing error messagesProkop Randáček
2025-11-16improve assembly error test coveragexdBronch
2025-11-14Sema: fix illegal multi level pointer coercionsJustus Klausecker
Moves a premature check that allowed pointers to mutable pointers to coerce to any other pointer to a mutable pointer.
2025-11-12Merge pull request #25772 from mlugg/kill-dead-codeMatthew Lugg
compiler: rewrite some legalizations, and remove a bunch of dead code
2025-11-12Sema: fix inline fn compiler crash (#25586)So1aric
Resolves: https://github.com/ziglang/zig/issues/25581
2025-11-12Air.Legalize: revert to loops for scalarizationsMatthew Lugg
I had tried unrolling the loops to avoid requiring the `vector_store_elem` instruction, but it's arguably a problem to generate O(N) code for an operation on `@Vector(N, T)`. In addition, that lowering emitted a lot of `.aggregate_init` instructions, which is itself a quite difficult operation to codegen. This requires reintroducing runtime vector indexing internally. However, I've put it in a couple of instructions which are intended only for use by `Air.Legalize`, named `legalize_vec_elem_val` (like `array_elem_val`, but for indexing a vector with a runtime-known index) and `legalize_vec_store_elem` (like the old `vector_store_elem` instruction). These are explicitly documented as *not* being emitted by Sema, so need only be implemented by backends if they actually use an `Air.Legalize.Feature` which emits them (otherwise they can be marked as `unreachable`).
2025-11-12compiler: spring cleaningMatthew Lugg
I started this diff trying to remove a little dead code from the C backend, but ended up finding a bunch of dead code sprinkled all over the place: * `packed` handling in the C backend which was made dead by `Legalize` * Representation of pointers to runtime-known vector indices * Handling for the `vector_store_elem` AIR instruction (now removed) * Old tuple handling from when they used the InternPool repr of structs * Straightforward unused functions * TODOs in the LLVM backend for features which Zig just does not support
2025-11-10Merge pull request #25886 from alexrp/kvxAlex Rønne Petersen
beginnings of KVX target support (via CBE)
2025-11-10sema: print @panic message at comptimexdBronch
2025-11-10std.Target: add Arch tag and info for kvxAlex Rønne Petersen
2025-11-07sema: disallow slices of opaque typesxdBronch
2025-10-30std.debug.lockStderrWriter: also return ttyconfMatthew Lugg
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving syscalls), and doing it every time we need to print isn't really necessary; under normal usage, we can compute the value once and cache it for the whole program's execution. Since anyone outputting to stderr may reasonably want this information (in fact they are very likely to), it makes sense to cache it and return it from `lockStderrWriter`. Call sites who do not need it will experience no significant overhead, and can just ignore the TTY config with a `const w, _` destructure.
2025-10-27feat: init x86_16 arch via CBEGasInfinity
2025-10-23Merge pull request #25640 from alexrp/std-target-more-archesAlex Rønne Petersen
`std.Target`: add tags and info for alpha, hppa, microblaze, sh + some bonus commits
2025-10-23std.builtin: move AddressSpace.Context to std.Target.AddressSpaceContextAlex Rønne Petersen
This type has nothing to do with the language.
2025-10-23std.builtin: add CallingConvention.sh_interruptAlex Rønne Petersen
Only supported in CBE.
2025-10-23std.builtin: add CallingConvention.microblaze_interruptAlex Rønne Petersen
Only supported in CBE.
2025-10-23std.builtin: add CallingConvention.msp430_interruptAlex Rønne Petersen
Supported by LLVM and CBE.
2025-10-23std.builtin: add CallingConvention.x86_64_x32Alex Rønne Petersen
This was forgotten during the refactoring of std.builtin.CallingConvention. It mirrors mips64_n32 for MIPS.
2025-10-23std.Target: add tags and info for alpha, hppa, microblaze, shAlex Rønne Petersen
2025-10-23spir-v: Fix .storage_buffer pointer indexingjonascloud
Renames arePointersLogical to shouldBlockPointerOps for clarity adds capability check to allow pointer ops on .storage_buffer when variable_pointers capability is enabled. Fixes #25638
2025-10-19compiler: add support for arc_interrupt calling conventionAlex Rønne Petersen
Only for use with the C backend at the moment.
2025-10-18Sema: or1k_sysv calling convention supports varargsAlex Rønne Petersen
2025-10-18std.Target: move Cpu.supportsAddressSpace() up to hereAlex Rønne Petersen
This allows us to rule out support for certain address spaces based on the OS. This commit is just a refactor, however, and doesn't actually make use of that opportunity yet.
2025-10-16detect invalid `@bitCast` with arraysxdBronch
2025-10-08don't make OPV tuple fields `comptime`xdBronch
2025-10-07don't make anonymous tuple fields referencing `comptime var`s `comptime`xdBronch
2025-10-07detect references to `comptime var` in default values and sentinelsxdBronch
2025-10-06don't pass zero-length `@memset` to the backendxdBronch
2025-09-30compiler: better crash handlermlugg
Far simpler, because everything which `crash_report.zig` did is now handled pretty well by `std.debug` anyway. All we want is to print some context around panics and segfaults. Using the new ability to override the default segfault handler while still having std handle the target-specific bits for us, that's really simple.
2025-09-24Compilation: re-implement cImportAndrew Kelley
2025-09-21Elf2: create a new linker from scratchJacob Young
This iteration already has significantly better incremental support. Closes #24110
2025-09-20Zcu: fix analysis of type of decl with inferred typemlugg
If the `nav_ty` is resolved by the `nav_val`, then we need to also mark the `nav_ty` as in progress when we begin resolving the `nav_val`.
2025-09-20Sema: add missed logic to checkPtrAttributesAndrew Kelley
It wasn't checking bit pointer data.
2025-09-20frontend: packed struct field ptr no longer finds byte bordersAndrew Kelley
technically breaking, but I doubt anyone will notice.