aboutsummaryrefslogtreecommitdiff
path: root/doc/langref
AgeCommit message (Collapse)Author
2025-10-26docs: fix handle_error_with_catch_block typoFelipe Cardozo
2025-09-20langref: don't assume too much about pointer to packed struct fieldAndrew Kelley
2025-09-18langref: runtime_shrExact_overflow does not work as expected on LoongArchAlex Rønne Petersen
https://github.com/ziglang/zig/issues/24304
2025-09-10langref: added missing newlines to destructuring tuples exampleLukaTD
langref: added missing newlines to destructuring tuples example
2025-09-07frontend: vectors and arrays no longer support in-memory coercionAndrew Kelley
closes #25172
2025-08-17langref: add documentation for unions with inferred tag and explicit tag valuesJustus Klausecker
2025-08-12Sema: Improve comptime arithmetic undef handlingJustus Klausecker
This commit expands on the foundations laid by https://github.com/ziglang/zig/pull/23177 and moves even more `Sema`-only functionality from `Value` to `Sema.arith`. Specifically all shift and bitwise operations, `@truncate`, `@bitReverse` and `@byteSwap` have been moved and adapted to the new rules around `undefined`. Especially the comptime shift operations have been basically rewritten, fixing many open issues in the process. New rules applied to operators: * `<<`, `@shlExact`, `@shlWithOverflow`, `>>`, `@shrExact`: compile error if any operand is undef * `<<|`, `~`, `^`, `@truncate`, `@bitReverse`, `@byteSwap`: return undef if any operand is undef * `&`, `|`: Return undef if both operands are undef, turn undef into actual `0xAA` bytes otherwise Additionally this commit canonicalizes the representation of aggregates with all-undefined members in the `InternPool` by disallowing them and enforcing the usage of a single typed `undef` value instead. This reduces the amount of edge cases and fixes a bunch of bugs related to partially undefined vecs. List of operations directly affected by this patch: * `<<`, `<<|`, `@shlExact`, `@shlWithOverflow` * `>>`, `@shrExact` * `&`, `|`, `~`, `^` and their atomic rmw + reduce pendants * `@truncate`, `@bitReverse`, `@byteSwap`
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-08-05std: remove BoundedArrayAndrew Kelley
This use case is handled by ArrayListUnmanaged via the "...Bounded" method variants, and it's more optimal to share machine code, versus generating multiple versions of each function for differing array lengths.
2025-07-28Merge branch 'ziglang:master' into some-documentation-updates-0Rue
2025-07-26Migrate from deprecated `Step.Compile` APIsCarl Åstholm
2025-07-22`[:x]T` coerces into `[*:x]T`IOKG04
https://github.com/ziglang/zig/issues/9628
2025-07-16update docsAndrew Kelley
2025-07-14langref: remove dead codeAlex Kladov
2025-07-14langref: don't encourage printing to stderr in testsAlex Kladov
The rule: `pub fn main` owns file descriptors 0, 1, and 2. If you didn't write `pub fn main()` it is, in general, not your business to print to stderr.
2025-07-14langref: make example more interesting.Alex Kladov
As written, I think langref's example is actually a poor reason to use `inline`. If you have if (foo(1200, 34) != 1234) { @compileError("bad"); } and you want to make sure that the call is executed at compile time, the right way to fix it is to add comptime if (comptime foo(1200, 34) != 1234) { @compileError("bad"); } and not to make the function `inline`. I _think_ that inlining functions just to avoid `comptime` at a call-site is an anti-pattern. When the reader sees `foo(123)` at the call-site, they _expect_ this to be a runtime call, as that's the normal rule in Zig. Inline is still necessary when you can't make the _whole_ call `comptime`, because it has some runtime effects, but you still want comptime-known result. A good example here is inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, comptime dep_name: []const u8) []const u8 { from Build.zig, where the `b` argument is runtime, and is used for side-effects, but where the result is comptime. I don't know of a good small example to demonstrate the subtelty here, so I went ahead with just adding a runtime print to `foo`. Hopefully it'll be enough for motivated reader to appreciate the subtelty!
2025-07-11Remove numerous things deprecated during the 0.14 release cycleLinus Groh
Basically everything that has a direct replacement or no uses left. Notable omissions: - std.ArrayHashMap: Too much fallout, needs a separate cleanup. - std.debug.runtime_safety: Too much fallout. - std.heap.GeneralPurposeAllocator: Lots of references to it remain, not a simple find and replace as "debug allocator" is not equivalent to "general purpose allocator". - std.io.Reader: Is being reworked at the moment. - std.unicode.utf8Decode(): No replacement, needs a new API first. - Manifest backwards compat options: Removal would break test data used by TestFetchBuilder. - panic handler needs to be a namespace: Many tests still rely on it being a function, needs a separate cleanup.
2025-07-07update standalone and incremental tests to new APIAndrew Kelley
2025-07-07remove `usingnamespace` from the languageAndrew Kelley
closes #20663
2025-07-01langref: runtime_shrExact_overflow does not work as expected on RISC-VAlex Rønne Petersen
https://github.com/ziglang/zig/issues/24304
2025-06-06langref: global assembly test depends on llvmAndrew Kelley
see #24046
2025-06-01compiler: combine `@intCast` safety checksmlugg
`castTruncatedData` was a poorly worded error (all shrinking casts "truncate bits", it's just that we assume those bits to be zext/sext of the other bits!), and `negativeToUnsigned` was a pointless distinction which forced the compiler to emit worse code (since two separate safety checks were required for casting e.g. 'i32' to 'u16') and wasn't even implemented correctly. This commit combines those safety panics into one function, `integerOutOfBounds`. The name maybe isn't perfect, but that's not hugely important; what matters is the new default message, which is clearer than the old ones: "integer does not fit in destination type".
2025-05-30langref: Update calling convention (#24022)Felix Rabe
* langref: Update calling convention * Apply suggestions from code review Co-authored-by: Alex Rønne Petersen <alex@alexrp.com> * langref: Just use .winapi directly --------- Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-04-15langref: reword some packed struct text and exampleAndrew Kelley
2025-04-15langref: packed struct documentationkj4tmp@gmail.com
2025-03-26Clarify the multidimensional array exampleAndrew Barchuk
Use a rectangular matrix instead of a square one to distinguish rows and columns more clearly. Extend the example with row access.
2025-03-06langref: update splat sectionKiëd Llaentenn
2025-03-05Remove uses of deprecated callconv aliasesLinus Groh
2025-02-28Revert "Merge pull request #22898 from kristoff-it/deprecated-proposal"Andrew Kelley
This reverts commit dea72d15da4fba909dc3ccb2e9dc5286372ac023, reversing changes made to ab381933c87bcc744058d25a876cfdc0d23fc674. The changeset does not work as advertised and does not have sufficient test coverage. Reopens #22822
2025-02-26`@deprecated`: add langref entryLoris Cro
2025-02-22langref: document modules, root source files, etcmlugg
2025-02-22langref: embrace the term "illegal behavior"mlugg
Also standardise the terms "safety-checked" and "unchecked".
2025-02-09std.BoundedArray: popOrNull() -> pop() [v2] (#22723)Meghan Denny
2025-01-28langref: Document destructuring (#21627)87
2024-11-26revert langref section "common errdefer slip ups"Andrew Kelley
This does not belong in the language reference. reverts 91a88a789ffa80ebb57c77ae0fe37594276e3707
2024-11-13langref: delete misleading example code about packed structsAndrew Kelley
2024-10-29typo: will inlined -> will be inlinedRoman Frołow
2024-10-19langref: update `enum_export_error.zig` for callconv changesmlugg
2024-10-12implement packed struct equality (#21679)David Rubin
2024-09-12Labeled switch documentation (#21383)LiterallyVoid
Add langref docs for labeled switch This feature was proposed in #8220, and implemented in #21257. Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-09-10remove explicit ComplexTypeTag from switchJesse Wattenbarger
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-27compiler,lib,test,langref: migrate `@setCold` to `@branchHint`mlugg
2024-08-27lib,test,tools,doc: update usages of @exportmlugg
2024-08-14langref: clarify functionality of the round builtin (#19503)T
A test has also been added to demonstrate the expected behavior. * std.math: update round doc comment to match the builtin
2024-07-29langref: Make pointer_coerce_const_optional test less obfuscatedRyan Liptak
This test was originally introduced in 5f38d6e2e97829ed74f06a96b5d07a2c68516063, where it looked like this: test "cast *[1][*]const u8 to [*]const ?[*]const u8" { const window_name = [1][*]const u8{c"window name"}; const x: [*]const ?[*]const u8 = &window_name; assert(mem.eql(u8, std.cstr.toSliceConst(x[0].?), "window name")); } Over the years, this has become more and more obfuscated, to the point that the verbosity of the `expect` call overshadows the point of the example. This commit intends to update this test to match the spirit of the original version of the test, while shedding the obfuscation.
2024-07-21langref: add example for errdefer |err| sytnaxAlex Kladov
2024-07-21single pointer slice syntax addedssmid
2024-07-15Sema: support pointer subtractionWooster