Signed integer operands must be comptime-known and positive. In other cases, use
{#link|@divTrunc#},
{#link|@divFloor#}, or
@@ -1393,7 +1401,7 @@ a %= b{#endsyntax#}
- Can cause {#link|Division by Zero#} for integers.
- - Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.Optimized Mode|Floating Point Operations#}.
+ - Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.optimized Mode|Floating Point Operations#}.
- Signed or floating-point operands must be comptime-known and positive. In other cases, use
{#link|@rem#} or
{#link|@mod#} instead.
@@ -2096,8 +2104,9 @@ or
less than {#syntax#}1 << 29{#endsyntax#}.
- In Zig, a pointer type has an alignment value. If the value is equal to the
- alignment of the underlying type, it can be omitted from the type:
+ Pointer types may explicitly specify an alignment in bytes. If it is not
+ specified, the alignment is assumed to be equal to the alignment of the
+ underlying type.
{#code|test_variable_alignment.zig#}
@@ -2461,7 +2470,8 @@ or
{#header_open|Tagged union#}
Unions can be declared with an enum tag type.
This turns the union into a tagged union, which makes it eligible
- to use with {#link|switch#} expressions.
+ to use with {#link|switch#} expressions. When switching on tagged unions,
+ the tag value can be obtained using an additional capture.
Tagged unions coerce to their tag type: {#link|Type Coercion: Unions and Enums#}.
{#code|test_tagged_union.zig#}
@@ -2504,6 +2514,13 @@ or
A {#syntax#}packed union{#endsyntax#} has well-defined in-memory layout and is eligible
to be in a {#link|packed struct#}.
All fields in a packed union must have the same {#link|@bitSizeOf#}.
+
+
+ Equating packed unions results in a comparison of the backing integer,
+ and only works for the {#syntax#}=={#endsyntax#} and {#syntax#}!={#endsyntax#} {#link|Operators#}.
+
+ {#code|test_packed_union_equality.zig#}
+
{#header_close#}
{#header_open|Anonymous Union Literals#}
@@ -2594,6 +2611,13 @@ or
{#header_close#}
+ {#header_open|Switching on Errors#}
+
+ When switching on errors, some special cases are allowed to simplify generic programming patterns:
+
+ {#code|test_switch_on_errors.zig#}
+ {#header_close#}
+
{#header_open|Labeled switch#}
When a switch statement is labeled, it can be referenced from a
@@ -2659,12 +2683,13 @@ or
{#code|test_inline_else.zig#}
- When using an inline prong switching on an union an additional
- capture can be used to obtain the union's enum tag value.
+ When using an inline prong switching on an union an additional capture
+ can be used to obtain the union's enum tag value at comptime, even though
+ its payload might only be known at runtime.
{#code|test_inline_switch_union_tag.zig#}
- {#see_also|inline while|inline for#}
+ {#see_also|inline while|inline for|Tagged union#}
{#header_close#}
{#header_close#}
@@ -3239,7 +3264,7 @@ fn createFoo(param: i32) !Foo {
- Return an error from main
- An error makes its way to {#syntax#}catch unreachable{#endsyntax#} and you have not overridden the default panic handler
- - Use {#link|errorReturnTrace#} to access the current return trace. You can use {#syntax#}std.debug.dumpStackTrace{#endsyntax#} to print it. This function returns comptime-known {#link|null#} when building without error return tracing support.
+ - Use {#link|errorReturnTrace#} to access the current return trace. You can use {#syntax#}std.debug.dumpErrorReturnTrace{#endsyntax#} to print it. This function returns comptime-known {#link|null#} when building without error return tracing support.
{#header_open|Implementation Details#}
@@ -3449,6 +3474,52 @@ void do_a_thing(struct Foo *foo) {
{#code|test_integer_widening.zig#}
+ {#header_close#}
+ {#header_open|Type Coercion: Int to Float#}
+
+ {#link|Integers#} coerce to {#link|Floats#} if every possible integer value can be stored in the float
+ without rounding (i.e. the integer's precision does not exceed the float's significand precision).
+ Larger integer types that cannot be safely coerced must be explicitly casted with {#link|@floatFromInt#}.
+
+
+
+
+
+ | Float Type |
+ Largest Integer Types |
+
+
+
+
+ | {#syntax#}f16{#endsyntax#} |
+ {#syntax#}i12{#endsyntax#} and {#syntax#}u11{#endsyntax#} |
+
+
+ | {#syntax#}f32{#endsyntax#} |
+ {#syntax#}i25{#endsyntax#} and {#syntax#}u24{#endsyntax#} |
+
+
+ | {#syntax#}f64{#endsyntax#} |
+ {#syntax#}i54{#endsyntax#} and {#syntax#}u53{#endsyntax#} |
+
+
+ | {#syntax#}f80{#endsyntax#} |
+ {#syntax#}i65{#endsyntax#} and {#syntax#}u64{#endsyntax#} |
+
+
+ | {#syntax#}f128{#endsyntax#} |
+ {#syntax#}i114{#endsyntax#} and {#syntax#}u113{#endsyntax#} |
+
+
+ | {#syntax#}c_longdouble{#endsyntax#} |
+ Varies by target |
+
+
+
+
+ {#code|test_int_to_float_coercion.zig#}
+ {#code|test_failed_int_to_float_coercion.zig#}
+
{#header_close#}
{#header_open|Type Coercion: Float to Int#}
@@ -3512,12 +3583,10 @@ void do_a_thing(struct Foo *foo) {
{#header_close#}
{#header_open|Explicit Casts#}
-
- Explicit casts are performed via {#link|Builtin Functions#}.
- Some explicit casts are safe; some are not.
- Some explicit casts perform language-level assertions; some do not.
- Some explicit casts are no-ops at runtime; some are not.
-
+ Explicit casts are performed via {#link|Builtin Functions#}.
+ Some explicit casts can violate type safety when used incorrectly.
+ Some explicit casts perform language-level assertions.
+ Some explicit casts are no-ops at runtime.
- {#link|@bitCast#} - change type but maintain bit representation
- {#link|@alignCast#} - make a pointer have more alignment
@@ -3530,7 +3599,7 @@ void do_a_thing(struct Foo *foo) {
- {#link|@intFromBool#} - convert true to 1 and false to 0
- {#link|@intFromEnum#} - obtain the integer tag value of an enum or tagged union
- {#link|@intFromError#} - obtain the integer value of an error code
- - {#link|@intFromFloat#} - obtain the integer part of a float value
+ - {#link|@round#}, {#link|@floor#}, {#link|@ceil#}, {#link|@trunc#} - float to integer conversion
- {#link|@intFromPtr#} - obtain the address of a pointer
- {#link|@ptrFromInt#} - convert an address to a pointer
- {#link|@ptrCast#} - convert between pointer types
@@ -4803,7 +4872,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_close#}
{#header_open|@errorFromInt#}
- {#syntax#}@errorFromInt(value: std.meta.Int(.unsigned, @bitSizeOf(anyerror))) anyerror{#endsyntax#}
+ {#syntax#}@errorFromInt(value: @Int(.unsigned, @bitSizeOf(anyerror))) anyerror{#endsyntax#}
Converts from the integer representation of an error into {#link|The Global Error Set#} type.
@@ -4924,8 +4993,9 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#syntax#}@floatFromInt(int: anytype) anytype{#endsyntax#}
Converts an integer to the closest floating point representation. The return type is the inferred result type.
- To convert the other way, use {#link|@intFromFloat#}. This operation is legal
- for all values of all integer types.
+ To convert the other way, use {#link|@round#}, {#link|@floor#},
+ {#link|@ceil#}, or {#link|@trunc#}. This operation is legal for all
+ values of all integer types.
{#header_close#}
@@ -5044,7 +5114,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_close#}
{#header_open|@intFromError#}
- {#syntax#}@intFromError(err: anytype) std.meta.Int(.unsigned, @bitSizeOf(anyerror)){#endsyntax#}
+ {#syntax#}@intFromError(err: anytype) @Int(.unsigned, @bitSizeOf(anyerror)){#endsyntax#}
Supports the following types:
@@ -5065,14 +5135,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_open|@intFromFloat#}
{#syntax#}@intFromFloat(float: anytype) anytype{#endsyntax#}
-
- Converts the integer part of a floating point number to the inferred result type.
-
-
- If the integer part of the floating point number cannot fit in the destination type,
- it invokes safety-checked {#link|Illegal Behavior#}.
-
- {#see_also|@floatFromInt#}
+ Deprecated. Equivalent to {#link|@trunc#}.
+ {#see_also|@floatFromInt|@round|@floor|@ceil|@trunc#}
{#header_close#}
{#header_open|@intFromPtr#}
@@ -5353,10 +5417,10 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
Changes the current scope's rules about how floating point operations are defined.
-
- {#syntax#}Strict{#endsyntax#} (default) - Floating point operations follow strict IEEE compliance.
+ {#syntax#}.strict{#endsyntax#} (default) - Floating point operations follow strict IEEE compliance.
-
- {#syntax#}Optimized{#endsyntax#} - Floating point operations may do all of the following:
+ {#syntax#}.optimized{#endsyntax#} - Floating point operations may do all of the following:
- Assume the arguments and result are not NaN. Optimizations are required to retain legal behavior over NaNs, but the value of the result is undefined.
- Assume the arguments and result are not +/-Inf. Optimizations are required to retain legal behavior over +/-Inf, but the value of the result is undefined.
@@ -5530,7 +5594,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
Note that {#syntax#}.Add{#endsyntax#} and {#syntax#}.Mul{#endsyntax#}
reductions on integral types are wrapping; when applied on floating point
types the operation associativity is preserved, unless the float mode is
- set to {#syntax#}Optimized{#endsyntax#}.
+ set to {#syntax#}.optimized{#endsyntax#}.
{#code|test_reduce_builtin.zig#}
@@ -5651,47 +5715,51 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
Supports {#link|Floats#}, {#link|Integers#} and {#link|Vectors#} of floats or integers.
{#header_close#}
+
{#header_open|@floor#}
{#syntax#}@floor(value: anytype) @TypeOf(value){#endsyntax#}
-
- Returns the largest integral value not greater than the given floating point number.
- Uses a dedicated hardware instruction when available.
-
-
- Supports {#link|Floats#} and {#link|Vectors#} of floats.
-
+ Returns the largest integral value not greater than the given floating point number.
+ Uses a dedicated hardware instruction when available.
+ Supports {#link|Floats#} and {#link|Vectors#} of floats.
+ When the inferred result type is an {#link|integer|Integers#},
+ the integer part is extracted from the floored result. If that value
+ cannot fit in the destination type, it invokes safety-checked
+ {#link|Illegal Behavior#}.
{#header_close#}
+
{#header_open|@ceil#}
{#syntax#}@ceil(value: anytype) @TypeOf(value){#endsyntax#}
-
- Returns the smallest integral value not less than the given floating point number.
- Uses a dedicated hardware instruction when available.
-
-
- Supports {#link|Floats#} and {#link|Vectors#} of floats.
-
+ Returns the smallest integral value not less than the given floating point number.
+ Uses a dedicated hardware instruction when available.
+ Supports {#link|Floats#} and {#link|Vectors#} of floats.
+ When the inferred result type is an {#link|integer|Integers#},
+ the integer part is extracted from the ceiled result. If that value
+ cannot fit in the destination type, it invokes safety-checked
+ {#link|Illegal Behavior#}.
{#header_close#}
+
{#header_open|@trunc#}
{#syntax#}@trunc(value: anytype) @TypeOf(value){#endsyntax#}
-
- Rounds the given floating point number to an integer, towards zero.
- Uses a dedicated hardware instruction when available.
-
-
- Supports {#link|Floats#} and {#link|Vectors#} of floats.
-
+ Rounds the given floating point number to an integer, towards zero.
+ Uses a dedicated hardware instruction when available.
+ Supports {#link|Floats#} and {#link|Vectors#} of float parameters.
+ When the inferred result type is an {#link|integer|Integers#},
+ the integer part is extracted from the truncated result. If that value
+ cannot fit in the destination type, it invokes safety-checked
+ {#link|Illegal Behavior#}.
{#header_close#}
+
{#header_open|@round#}
{#syntax#}@round(value: anytype) @TypeOf(value){#endsyntax#}
-
- Rounds the given floating point number to the nearest integer. If two integers are equally close, rounds away from zero.
- Uses a dedicated hardware instruction when available.
-
+ Rounds the given floating point number to the nearest integer. If two
+ integers are equally close, rounds away from zero. Uses a dedicated
+ hardware instruction when available.
{#code|test_round_builtin.zig#}
-
-
- Supports {#link|Floats#} and {#link|Vectors#} of floats.
-
+ Supports {#link|Floats#} and {#link|Vectors#} of floats.
+ When the inferred result type is an {#link|integer|Integers#},
+ the integer part is extracted from the rounded result. If that value
+ cannot fit in the destination type, it invokes safety-checked
+ {#link|Illegal Behavior#}.
{#header_close#}
{#header_open|@subWithOverflow#}
@@ -6305,7 +6373,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
Zig has a general purpose allocator available to be imported
- with {#syntax#}std.heap.GeneralPurposeAllocator{#endsyntax#}. However, it is still recommended to
+ with {#syntax#}std.heap.DebugAllocator{#endsyntax#}. However, it is still recommended to
follow the {#link|Choosing an Allocator#} guide.
@@ -7027,8 +7095,7 @@ WebAssembly.instantiate(typedArray, {
The result is 3{#end_shell_samp#}
{#header_close#}
{#header_open|WASI#}
- Zig's support for WebAssembly System Interface (WASI) is under active development.
- Example of using the standard library and reading command line arguments:
+ Zig standard library has first-class support for WebAssembly System Interface.
{#code|wasi_args.zig#}
{#shell_samp#}$ wasmtime wasi_args.wasm 123 hello
@@ -7090,6 +7157,7 @@ coding style.
- Data
- Context
- Manager
+ - State
- utils, misc, or somebody's initials
Everything is a value, all types are data, everything is context, all logic manages state.
@@ -7115,6 +7183,31 @@ coding style.
cannot be any more specific without being incorrect.
{#header_close#}
+ {#header_open|Refrain from Underscore Prefixes#}
+ In some programming languages, it is common to prefix identifiers with
+ underscores {#syntax#}_like_this{#endsyntax#} to avoid keyword
+ collisions, name collisions, or indicate additional metadata associated with usage of the
+ identifier, such as: privacy, existence of complex data invariants, exclusion from
+ semantic versioning, or context-specific type reflection meaning.
+
+ In Zig, there are no private fields, and this style guide recommends
+ against pretending otherwise. Instead, fields should be named carefully
+ based on their semantics and documentation should indicate how to use
+ fields without violating data invariants. If a field is not subject to
+ the same semantic versioning rules as everything else, the exception
+ should be noted in the {#link|Doc Comments#}.
+
+ As for {#link|type reflection|@typeInfo#}, it is less error prone and
+ more maintainable to use the type system than to make field names
+ meaningful.
+ Regarding name collisions, an underscore is insufficient to explain
+ the difference between the two otherwise identical names. If there's no
+ danger in getting them mixed up, then this guide recommends more verbose
+ names at outer scopes and more abbreviated names at inner scopes.
+ Finally, keyword collisions are better avoided via
+ {#link|String Identifier Syntax#}.
+ {#header_close#}
+
{#header_open|Whitespace#}
-
@@ -7849,58 +7942,60 @@ TestDecl <- KEYWORD_test (STRINGLITERALSINGLE / IDENTIFIER)? Block
ComptimeDecl <- KEYWORD_comptime Block
Decl
- <- (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE? / KEYWORD_inline / KEYWORD_noinline)? FnProto (SEMICOLON / Block)
+ <- (KEYWORD_export / KEYWORD_inline / KEYWORD_noinline)? FnProto (SEMICOLON / Block)
+ / KEYWORD_extern STRINGLITERALSINGLE? FnProto SEMICOLON
/ (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? GlobalVarDecl
-FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? AddrSpace? LinkSection? CallConv? EXCLAMATIONMARK? TypeExpr
+FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? AddrSpace? LinkSection? CallConv? EXCLAMATIONMARK? TypeExpr !ExprSuffix
VarDeclProto <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? AddrSpace? LinkSection?
GlobalVarDecl <- VarDeclProto (EQUAL Expr)? SEMICOLON
-ContainerField <- doc_comment? KEYWORD_comptime? !KEYWORD_fn (IDENTIFIER COLON)? TypeExpr ByteAlign? (EQUAL Expr)?
+ContainerField <- doc_comment? (KEYWORD_comptime / !KEYWORD_comptime) !KEYWORD_fn (IDENTIFIER COLON / !(IDENTIFIER COLON))? TypeExpr ByteAlign? (EQUAL Expr)?
# *** Block Level ***
-Statement
- <- KEYWORD_comptime ComptimeStatement
- / KEYWORD_nosuspend BlockExprStatement
- / KEYWORD_suspend BlockExprStatement
+BlockStatement
+ <- Statement
/ KEYWORD_defer BlockExprStatement
/ KEYWORD_errdefer Payload? BlockExprStatement
- / IfStatement
- / LabeledStatement
- / VarDeclExprStatement
+ / !ExprStatement (KEYWORD_comptime !BlockExpr)? VarAssignStatement
-ComptimeStatement
- <- BlockExpr
- / VarDeclExprStatement
+Statement
+ <- ExprStatement
+ / KEYWORD_suspend BlockExprStatement
+ / !ExprStatement (KEYWORD_comptime !BlockExpr)? AssignExpr SEMICOLON
+
+ExprStatement
+ <- IfStatement
+ / LabeledStatement
+ / KEYWORD_nosuspend BlockExprStatement
+ / KEYWORD_comptime BlockExpr
IfStatement
<- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )?
- / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
+ / IfPrefix !BlockExpr AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
LabeledStatement <- BlockLabel? (Block / LoopStatement / SwitchExpr)
LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement)
ForStatement
- <- ForPrefix BlockExpr ( KEYWORD_else Statement )?
- / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement )
+ <- ForPrefix BlockExpr ( KEYWORD_else Statement / !KEYWORD_else )
+ / ForPrefix !BlockExpr AssignExpr ( SEMICOLON / KEYWORD_else Statement )
WhileStatement
<- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )?
- / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
+ / WhilePrefix !BlockExpr AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
BlockExprStatement
<- BlockExpr
- / AssignExpr SEMICOLON
+ / !BlockExpr AssignExpr SEMICOLON
BlockExpr <- BlockLabel? Block
-# An expression, assignment, or any destructure, as a statement.
-VarDeclExprStatement
- <- VarDeclProto (COMMA (VarDeclProto / Expr))* EQUAL Expr SEMICOLON
- / Expr (AssignOp Expr / (COMMA (VarDeclProto / Expr))+ EQUAL Expr)? SEMICOLON
+# An assignment or a destructure whose LHS are all lvalue expressions or variable declarations.
+VarAssignStatement <- (VarDeclProto / Expr) (COMMA (VarDeclProto / Expr))* EQUAL Expr SEMICOLON
# *** Expression Level ***
@@ -7930,25 +8025,25 @@ PrefixExpr <- PrefixOp* PrimaryExpr
PrimaryExpr
<- AsmExpr
/ IfExpr
- / KEYWORD_break BreakLabel? Expr?
- / KEYWORD_comptime Expr
- / KEYWORD_nosuspend Expr
- / KEYWORD_continue BreakLabel? Expr?
- / KEYWORD_resume Expr
- / KEYWORD_return Expr?
+ / KEYWORD_break (BreakLabel / !BreakLabel) (Expr !ExprSuffix / !SinglePtrTypeStart)
+ / KEYWORD_comptime Expr !ExprSuffix
+ / KEYWORD_nosuspend Expr !ExprSuffix
+ / KEYWORD_continue (BreakLabel / !BreakLabel) (Expr !ExprSuffix / !SinglePtrTypeStart)
+ / KEYWORD_resume Expr !ExprSuffix
+ / KEYWORD_return (Expr !ExprSuffix / !SinglePtrTypeStart)
/ BlockLabel? LoopExpr
/ Block
/ CurlySuffixExpr
-IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)?
+IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)? !ExprSuffix
-Block <- LBRACE Statement* RBRACE
+Block <- LBRACE BlockStatement* RBRACE
LoopExpr <- KEYWORD_inline? (ForExpr / WhileExpr)
-ForExpr <- ForPrefix Expr (KEYWORD_else Expr)?
+ForExpr <- ForPrefix Expr (KEYWORD_else Expr / !KEYWORD_else) !ExprSuffix
-WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)?
+WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)? !ExprSuffix
CurlySuffixExpr <- TypeExpr InitList?
@@ -7975,10 +8070,10 @@ PrimaryTypeExpr
/ FnProto
/ GroupedExpr
/ LabeledTypeExpr
- / IDENTIFIER
+ / IDENTIFIER !(COLON LabelableExpr)
/ IfTypeExpr
/ INTEGER
- / KEYWORD_comptime TypeExpr
+ / KEYWORD_comptime TypeExpr !ExprSuffix
/ KEYWORD_error DOT IDENTIFIER
/ KEYWORD_anyframe
/ KEYWORD_unreachable
@@ -7990,7 +8085,7 @@ ErrorSetDecl <- KEYWORD_error LBRACE IdentifierList RBRACE
GroupedExpr <- LPAREN Expr RPAREN
-IfTypeExpr <- IfPrefix TypeExpr (KEYWORD_else Payload? TypeExpr)?
+IfTypeExpr <- IfPrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? !ExprSuffix
LabeledTypeExpr
<- BlockLabel Block
@@ -7999,9 +8094,9 @@ LabeledTypeExpr
LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr)
-ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)?
+ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr / !KEYWORD_else) !ExprSuffix
-WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)?
+WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? !ExprSuffix
SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE
@@ -8010,11 +8105,11 @@ AsmExpr <- KEYWORD_asm KEYWORD_volatile? LPAREN Expr AsmOutput? RPAREN
AsmOutput <- COLON AsmOutputList AsmInput?
-AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN
+AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERALSINGLE LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN
AsmInput <- COLON AsmInputList AsmClobbers?
-AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN
+AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERALSINGLE LPAREN Expr RPAREN
AsmClobbers <- COLON Expr
@@ -8034,9 +8129,7 @@ AddrSpace <- KEYWORD_addrspace LPAREN Expr RPAREN
# Fn specific
CallConv <- KEYWORD_callconv LPAREN Expr RPAREN
-ParamDecl
- <- doc_comment? (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
- / DOT3
+ParamDecl <- doc_comment? (KEYWORD_noalias / KEYWORD_comptime / !KEYWORD_comptime) (IDENTIFIER COLON / !(IDENTIFIER_COLON)) ParamType
ParamType
<- KEYWORD_anytype
@@ -8142,8 +8235,8 @@ PrefixOp
PrefixTypeOp
<- QUESTIONMARK
/ KEYWORD_anyframe MINUSRARROW
- / SliceTypeStart (ByteAlign / AddrSpace / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)*
- / PtrTypeStart (AddrSpace / KEYWORD_align LPAREN Expr (COLON Expr COLON Expr)? RPAREN / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)*
+ / (ManyPtrTypeStart / SliceTypeStart) KEYWORD_allowzero? ByteAlign? AddrSpace? KEYWORD_const? KEYWORD_volatile?
+ / SinglePtrTypeStart KEYWORD_allowzero? BitAlign? AddrSpace? KEYWORD_const? KEYWORD_volatile?
/ ArrayTypeStart
SuffixOp
@@ -8154,15 +8247,31 @@ SuffixOp
FnCallArguments <- LPAREN ExprList RPAREN
+ExprSuffix
+ <- KEYWORD_or
+ / KEYWORD_and
+ / CompareOp
+ / BitwiseOp
+ / BitShiftOp
+ / AdditionOp
+ / MultiplyOp
+ / EXCLAMATIONMARK
+ / SuffixOp
+ / FnCallArguments
+
+LabelableExpr
+ <- Block
+ / SwitchExpr
+ / LoopExpr
+
# Ptr specific
SliceTypeStart <- LBRACKET (COLON Expr)? RBRACKET
-PtrTypeStart
- <- ASTERISK
- / ASTERISK2
- / LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
+SinglePtrTypeStart <- ASTERISK / ASTERISK2
+
+ManyPtrTypeStart <- LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
-ArrayTypeStart <- LBRACKET Expr (COLON Expr)? RBRACKET
+ArrayTypeStart <- LBRACKET Expr !(ASTERISK / ASTERISK2) (COLON Expr)? RBRACKET
# ContainerDecl specific
ContainerDeclAuto <- ContainerDeclType LBRACE ContainerMembers RBRACE
@@ -8171,11 +8280,13 @@ ContainerDeclType
<- KEYWORD_struct (LPAREN Expr RPAREN)?
/ KEYWORD_opaque
/ KEYWORD_enum (LPAREN Expr RPAREN)?
- / KEYWORD_union (LPAREN (KEYWORD_enum (LPAREN Expr RPAREN)? / Expr) RPAREN)?
+ / KEYWORD_union (LPAREN (KEYWORD_enum (LPAREN Expr RPAREN)? / !KEYWORD_enum Expr) RPAREN)?
# Alignment
ByteAlign <- KEYWORD_align LPAREN Expr RPAREN
+BitAlign <- KEYWORD_align LPAREN Expr (COLON Expr COLON Expr)? RPAREN
+
# Lists
IdentifierList <- (doc_comment? IDENTIFIER COMMA)* (doc_comment? IDENTIFIER)?
@@ -8185,7 +8296,7 @@ AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem?
AsmInputList <- (AsmInputItem COMMA)* AsmInputItem?
-ParamDeclList <- (ParamDecl COMMA)* ParamDecl?
+ParamDeclList <- (ParamDecl COMMA)* (ParamDecl / DOT3 COMMA?)?
ExprList <- (Expr COMMA)* Expr?
@@ -8242,6 +8353,7 @@ multibyte_utf8 <-
/ oxC2_oxDF ox80_oxBF
non_control_ascii <- [\040-\176]
+non_control_utf8 <- [\040-\377]
char_escape
<- "\\x" hex hex
@@ -8257,10 +8369,10 @@ string_char
/ char_escape
/ ![\\"\n] non_control_ascii
-container_doc_comment <- ('//!' [^\n]* [ \n]* skip)+
-doc_comment <- ('///' [^\n]* [ \n]* skip)+
-line_comment <- '//' ![!/][^\n]* / '////' [^\n]*
-line_string <- ('\\\\' [^\n]* [ \n]*)+
+container_doc_comment <- ('//!' non_control_utf8* [ \n]* skip)+
+doc_comment <- ('///' non_control_utf8* [ \n]* skip)+
+line_comment <- '//' ![!/] non_control_utf8* / '////' non_control_utf8*
+line_string <- '\\\\' non_control_utf8* [ \n]*
skip <- ([ \n] / line_comment)*
CHAR_LITERAL <- ['] char_char ['] skip
diff --git a/tests/lsp_features/completion.zig b/tests/lsp_features/completion.zig
index 4ba071b0a..e2707393f 100644
--- a/tests/lsp_features/completion.zig
+++ b/tests/lsp_features/completion.zig
@@ -3897,8 +3897,8 @@ test "insert replace behaviour - builtin with snippets - @errorFromInt" {
try testCompletionTextEdit(.{
.source = "const foo = @;",
.label = "@errorFromInt",
- .expected_insert_line = "const foo = @errorFromInt(${1:value: std.meta.Int(.unsigned, @bitSizeOf(anyerror))});",
- .expected_replace_line = "const foo = @errorFromInt(${1:value: std.meta.Int(.unsigned, @bitSizeOf(anyerror))});",
+ .expected_insert_line = "const foo = @errorFromInt(${1:value: @Int(.unsigned, @bitSizeOf(anyerror))});",
+ .expected_replace_line = "const foo = @errorFromInt(${1:value: @Int(.unsigned, @bitSizeOf(anyerror))});",
.enable_snippets = true,
.enable_argument_placeholders = true,
});
From 852398e8d6f8a1e54709700cca4f79c0f6a7b0fe Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Tue, 14 Apr 2026 00:08:17 +0200
Subject: [PATCH 05/14] set minimum zig version to `0.16.0`
---
build.zig.zon | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.zig.zon b/build.zig.zon
index ab4ada332..4ea4dd512 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -10,7 +10,7 @@
// nix flake update --commit-lock-file
// ```
// If you do not use Nix, a ZLS maintainer can take care of this.
- .minimum_zig_version = "0.16.0-dev.3133+5ec8e45f3",
+ .minimum_zig_version = "0.16.0",
// Must be kept in sync with the `deps.nix` for the Nix flake.
// If you do not use Nix, a ZLS maintainer can take care of this.
.dependencies = .{
From cc425c4c7cdb24bbac79956ac15343ab4f8e6635 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Tue, 14 Apr 2026 00:08:33 +0200
Subject: [PATCH 06/14] set minimum runtime Zig version to `0.16.0`
---
build.zig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build.zig b/build.zig
index 0aa77cc73..d018b88db 100644
--- a/build.zig
+++ b/build.zig
@@ -6,10 +6,10 @@ const zls_version = std.SemanticVersion.parse(@import("build.zig.zon").version)
const minimum_build_zig_version = @import("build.zig.zon").minimum_zig_version;
/// Specify the minimum Zig version that is usable with ZLS:
-/// std.Io: move netReceive to become an Operation
+/// Release 0.16.0
///
/// A breaking change to the Zig Build System should be handled by updating ZLS's build runner (see src\build_runner)
-const minimum_runtime_zig_version = "0.16.0-dev.2736+3b515fbed";
+const minimum_runtime_zig_version = "0.16.0";
const release_targets = [_]std.Target.Query{
.{ .cpu_arch = .aarch64, .os_tag = .linux },
From 5102c185d79bab0750e1d62e34969a7b17eb4f84 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Tue, 14 Apr 2026 00:09:06 +0200
Subject: [PATCH 07/14] CI: use Zig 0.16.0
---
.github/workflows/artifacts.yml | 2 +-
.github/workflows/coverage.yml | 2 +-
.github/workflows/main.yml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml
index af2773a08..9510e66c7 100644
--- a/.github/workflows/artifacts.yml
+++ b/.github/workflows/artifacts.yml
@@ -39,7 +39,7 @@ jobs:
- uses: mlugg/setup-zig@v2
if: env.SKIP_DEPLOY != 'true'
with:
- version: master
+ version: 0.16.0
- name: Install APT packages
if: env.SKIP_DEPLOY != 'true'
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 433d25f3c..8db43c80b 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -16,7 +16,7 @@ jobs:
- uses: mlugg/setup-zig@v2
with:
- version: master
+ version: 0.16.0
- name: Install kcov
run: |
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 6407ff364..1844d1f98 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -20,7 +20,7 @@ jobs:
- uses: mlugg/setup-zig@v2
with:
- version: master
+ version: 0.16.0
- name: Run zig fmt
if: matrix.os == 'ubuntu-22.04'
From a237be50b4d075efb7a1e6ca11d087cf9f2e0fb7 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Thu, 16 Apr 2026 21:05:24 +0200
Subject: [PATCH 08/14] bump max RSS values for release artifact compilation
---
build.zig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.zig b/build.zig
index d018b88db..cfec30536 100644
--- a/build.zig
+++ b/build.zig
@@ -171,7 +171,7 @@ pub fn build(b: *Build) !void {
artifact.* = b.addExecutable(.{
.name = "zls",
.root_module = exe_module,
- .max_rss = if (optimize == .Debug and target_query.os_tag == .wasi) 2_200_000_000 else 1_800_000_000,
+ .max_rss = if (optimize == .Debug and target_query.os_tag == .wasi) 2_600_000_000 else 2_000_000_000,
.use_llvm = use_llvm,
.use_lld = use_llvm,
});
From 59bc7276e19944bd86c4b4ed2e42a7fa32924e26 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Tue, 14 Apr 2026 21:06:26 +0200
Subject: [PATCH 09/14] update dependencies
---
build.zig.zon | 12 ++++++------
deps.nix | 18 +++++++++---------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/build.zig.zon b/build.zig.zon
index 4ea4dd512..8837ff138 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -15,16 +15,16 @@
// If you do not use Nix, a ZLS maintainer can take care of this.
.dependencies = .{
.known_folders = .{
- .url = "https://github.com/ziglibs/known-folders/archive/175f5596b3d2ee3c658282bb07885580895a0e73.tar.gz",
- .hash = "known_folders-0.0.0-Fy-PJk7KAAC41mQXzmFyGa0Q7tvmQjatENkREa6Gc4zu",
+ .url = "https://github.com/ziglibs/known-folders/archive/d6d03830968cca6b7b9f24fd97ee348346a6905d.tar.gz",
+ .hash = "known_folders-0.0.0-Fy-PJk3KAACzUg2us_0JvQQmod1ZA8jBt7MuoKCihq88",
},
.diffz = .{
- .url = "https://github.com/ziglibs/diffz/archive/d93d5737d2c19a2fb279c8dcaa80a4ce35529a3b.tar.gz",
- .hash = "diffz-0.0.1-G2tlIXvNAQCPPTvl-leqv4d5nfEdwLw2lfE11P7EGKhy",
+ .url = "https://github.com/ziglibs/diffz/archive/b39fe07e7fdbcf56e43ba2890b9f484f16969f90.tar.gz",
+ .hash = "diffz-0.0.1-G2tlISzNAQCldmOcINavGmF1zdt20NFPXeM8d07jp_68",
},
.lsp_kit = .{
- .url = "https://github.com//zigtools/lsp-kit/archive/ec325a3c33d1da7708cf513355208f74d9560580.tar.gz",
- .hash = "lsp_kit-0.1.0-bi_PL_kyDACVTEhLaMq2-PJx0MocqRyjXDAN0ybMUyQQ",
+ .url = "https://github.com/zigtools/lsp-kit/archive/b886a2b0d5cee85ecbcc3089b863f7517cc9ff7f.tar.gz",
+ .hash = "lsp_kit-0.1.0-bi_PL3IyDACfp1xdTnkiOHEok2YpPCCCJHuuOcNzjl1D",
},
.tracy = .{
.url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.13.1.tar.gz",
diff --git a/deps.nix b/deps.nix
index b9b29bd5d..66b1fc35d 100644
--- a/deps.nix
+++ b/deps.nix
@@ -5,24 +5,24 @@
}:
linkFarm "zig-packages" [
{
- name = "known_folders-0.0.0-Fy-PJk7KAAC41mQXzmFyGa0Q7tvmQjatENkREa6Gc4zu";
+ name = "known_folders-0.0.0-Fy-PJk3KAACzUg2us_0JvQQmod1ZA8jBt7MuoKCihq88";
path = fetchzip {
- url = "https://github.com/ziglibs/known-folders/archive/4575ac4088eb7d0c8421d5b3d642f19de392d898.tar.gz";
- hash = "sha256-YE4KRNvrqzMtB7sSPnnbhwCokfNP7RqNtO1QVgwbiBc=";
+ url = "https://github.com/ziglibs/known-folders/archive/d6d03830968cca6b7b9f24fd97ee348346a6905d.tar.gz";
+ hash = "sha256-8LlAnEwuoeQuN9V5nUuh2UwXRhS5KOwDkpm6yuOfClk=";
};
}
{
- name = "diffz-0.0.1-G2tlIXvNAQCPPTvl-leqv4d5nfEdwLw2lfE11P7EGKhy";
+ name = "diffz-0.0.1-G2tlISzNAQCldmOcINavGmF1zdt20NFPXeM8d07jp_68";
path = fetchzip {
- url = "https://github.com/ziglibs/diffz/archive/d93d5737d2c19a2fb279c8dcaa80a4ce35529a3b.tar.gz";
- hash = "sha256-1IDqdr0+74IlH76eovC6m5Ww6bNMAAyHFt1ukat/UXk=";
+ url = "https://github.com/ziglibs/diffz/archive/b39fe07e7fdbcf56e43ba2890b9f484f16969f90.tar.gz";
+ hash = "sha256-mmgaOXFpoBYMsNdVkoFa7wJKkiXtzXIbSxRUgWLdVUc=";
};
}
{
- name = "lsp_kit-0.1.0-bi_PL_kyDACVTEhLaMq2-PJx0MocqRyjXDAN0ybMUyQQ";
+ name = "lsp_kit-0.1.0-bi_PL3IyDACfp1xdTnkiOHEok2YpPCCCJHuuOcNzjl1D";
path = fetchzip {
- url = "https://github.com/zigtools/lsp-kit/archive/ec325a3c33d1da7708cf513355208f74d9560580.tar.gz";
- hash = "sha256-60F2BOCrl3CreQFmpH3HAz6zzxd3VgJ3iSEkP39gtgQ=";
+ url = "https://github.com/zigtools/lsp-kit/archive/b886a2b0d5cee85ecbcc3089b863f7517cc9ff7f.tar.gz";
+ hash = "sha256-367wPydvnpl9RYlTrXwk4bZ/ui9DbYjeY/VDYs7ZJRs=";
};
}
]
From 558c72b2bccc23dd40fd7e130f96f7a588958fdb Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Thu, 16 Apr 2026 21:05:37 +0200
Subject: [PATCH 10/14] update documentation of `skip_std_references` config
option
---
schema.json | 2 +-
src/Config.zig | 2 +-
src/tools/config.json | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/schema.json b/schema.json
index beafb5634..c7ee96244 100644
--- a/schema.json
+++ b/schema.json
@@ -93,7 +93,7 @@
"default": false
},
"skip_std_references": {
- "description": "When true, skips searching for references in the standard library. Improves lookup speed for functions in user's code. Renaming and go-to-definition will continue to work as is",
+ "description": "No longer used. May be brought back to configure how symbol references in the standard library should behave",
"type": "boolean",
"default": false
},
diff --git a/src/Config.zig b/src/Config.zig
index 7268a5a80..846e0e73b 100644
--- a/src/Config.zig
+++ b/src/Config.zig
@@ -60,7 +60,7 @@ warn_style: bool = false,
/// Whether to highlight global var declarations
highlight_global_var_declarations: bool = false,
-/// When true, skips searching for references in the standard library. Improves lookup speed for functions in user's code. Renaming and go-to-definition will continue to work as is
+/// No longer used. May be brought back to configure how symbol references in the standard library should behave
skip_std_references: bool = false,
/// Favor using `zig ast-check` instead of the builtin one
diff --git a/src/tools/config.json b/src/tools/config.json
index e6a4f59c9..3bfd193df 100644
--- a/src/tools/config.json
+++ b/src/tools/config.json
@@ -103,7 +103,7 @@
},
{
"name": "skip_std_references",
- "description": "When true, skips searching for references in the standard library. Improves lookup speed for functions in user's code. Renaming and go-to-definition will continue to work as is",
+ "description": "No longer used. May be brought back to configure how symbol references in the standard library should behave",
"type": "bool",
"default": false
},
From 3f4ac9f643bcd1998759d331908a0c25017dcd45 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Thu, 16 Apr 2026 20:52:44 +0200
Subject: [PATCH 11/14] update set of excluded builtin parameter inlay hints
---
src/features/inlay_hints.zig | 256 ++++++++++++++++++-----------------
1 file changed, 133 insertions(+), 123 deletions(-)
diff --git a/src/features/inlay_hints.zig b/src/features/inlay_hints.zig
index c3afbd5f3..9ffef22bd 100644
--- a/src/features/inlay_hints.zig
+++ b/src/features/inlay_hints.zig
@@ -16,127 +16,136 @@ const data = @import("version_data");
/// don't show inlay hints for builtin functions whose parameter names carry no
/// meaningful information or are trivial deductible based on the builtin name.
-const excluded_builtins_set: std.StaticStringMap(void) = blk: {
- @setEvalBranchQuota(2000);
- break :blk .initComptime(.{
- .{"addrSpaceCast"},
- .{"addWithOverflow"},
- .{"alignCast"},
- .{"alignOf"},
- .{"as"},
- // .{"atomicLoad"},
- // .{"atomicRmw"},
- // .{"atomicStore"},
- .{"bitCast"},
- .{"bitOffsetOf"},
- .{"bitSizeOf"},
- .{"branchHint"},
- .{"breakpoint"}, // no parameters
- // .{"mulAdd"},
- .{"byteSwap"},
- .{"bitReverse"},
- .{"offsetOf"},
- // .{"call"},
- .{"cDefine"},
- .{"cImport"},
- .{"cInclude"},
- .{"clz"},
- // .{"cmpxchgStrong"},
- // .{"cmpxchgWeak"},
- // .{"compileError"},
- .{"compileLog"}, // variadic
- .{"constCast"},
- .{"ctz"},
- .{"cUndef"},
- // .{"cVaArg"},
- // .{"cVaCopy"},
- // .{"cVaEnd"},
- // .{"cVaStart"},
- .{"divExact"},
- .{"divFloor"},
- .{"divTrunc"},
- .{"embedFile"},
- .{"enumFromInt"},
- .{"errorFromInt"},
- .{"errorName"},
- .{"errorReturnTrace"}, // no parameters
- .{"errorCast"},
- // .{"export"},
- // .{"extern"},
- // .{"field"},
- // .{"fieldParentPtr"},
- // .{"FieldType"},
- .{"floatCast"},
- .{"floatFromInt"},
- .{"frameAddress"}, // no parameters
- // .{"hasDecl"},
- // .{"hasField"},
- .{"import"},
- .{"inComptime"}, // no parameters
- .{"intCast"},
- .{"intFromBool"},
- .{"intFromEnum"},
- .{"intFromError"},
- .{"intFromFloat"},
- .{"intFromPtr"},
- .{"max"},
- // .{"memcpy"},
- // .{"memset"},
- .{"min"},
- // .{"wasmMemorySize"},
- // .{"wasmMemoryGrow"},
- .{"mod"},
- .{"mulWithOverflow"},
- // .{"panic"},
- .{"popCount"},
- // .{"prefetch"},
- .{"ptrCast"},
- .{"ptrFromInt"},
- .{"rem"},
- .{"returnAddress"}, // no parameters
- // .{"select"},
- .{"setEvalBranchQuota"},
- .{"setFloatMode"},
- .{"setRuntimeSafety"},
- // .{"shlExact"},
- // .{"shlWithOverflow"},
- // .{"shrExact"},
- // .{"shuffle"},
- .{"sizeOf"},
- // .{"splat"},
- // .{"reduce"},
- .{"src"}, // no parameters
- .{"sqrt"},
- .{"sin"},
- .{"cos"},
- .{"tan"},
- .{"exp"},
- .{"exp2"},
- .{"log"},
- .{"log2"},
- .{"log10"},
- .{"abs"},
- .{"floor"},
- .{"ceil"},
- .{"trunc"},
- .{"round"},
- .{"subWithOverflow"},
- .{"tagName"},
- .{"This"}, // no parameters
- .{"trap"}, // no parameters
- .{"truncate"},
- .{"Type"},
- .{"typeInfo"},
- .{"typeName"},
- .{"TypeOf"}, // variadic
- // .{"unionInit"},
- // .{"Vector"},
- .{"volatileCast"},
- // .{"workGroupId"},
- // .{"workGroupSize"},
- // .{"workItemId"},
- });
-};
+const excluded_builtins_set: std.EnumArray(std.zig.BuiltinFn.Tag, bool) = .init(.{
+ .add_with_overflow = true,
+ .addrspace_cast = true,
+ .align_cast = true,
+ .align_of = true,
+ .as = true,
+ .atomic_load = false,
+ .atomic_rmw = false,
+ .atomic_store = false,
+ .bit_cast = true,
+ .bit_offset_of = true,
+ .int_from_bool = true,
+ .bit_size_of = true,
+ .branch_hint = true,
+ .breakpoint = true, // no parameters
+ .disable_instrumentation = true, // no parameters
+ .disable_intrinsics = true, // no parameters
+ .mul_add = false,
+ .byte_swap = true,
+ .bit_reverse = true,
+ .offset_of = false,
+ .call = false,
+ .c_define = true,
+ .c_import = true,
+ .c_include = true,
+ .clz = true,
+ .cmpxchg_strong = false,
+ .cmpxchg_weak = false,
+ .compile_error = false,
+ .compile_log = true, // variadic
+ .const_cast = true,
+ .ctz = true,
+ .c_undef = true,
+ .c_va_arg = false,
+ .c_va_copy = false,
+ .c_va_end = false,
+ .c_va_start = false,
+ .div_exact = true,
+ .div_floor = true,
+ .div_trunc = true,
+ .embed_file = true,
+ .int_from_enum = true,
+ .error_name = true,
+ .error_return_trace = true, // no parameters
+ .int_from_error = true,
+ .error_cast = true,
+ .@"export" = false,
+ .@"extern" = false,
+ .field = false,
+ .field_parent_ptr = false,
+ .FieldType = false,
+ .float_cast = true,
+ .int_from_float = true,
+ .frame = true,
+ .Frame = true,
+ .frame_address = true, // no parameters
+ .has_decl = false,
+ .has_field = false,
+ .import = true,
+ .in_comptime = true, // no parameters
+ .int_cast = true,
+ .enum_from_int = true,
+ .error_from_int = true,
+ .float_from_int = true,
+ .ptr_from_int = true,
+ .max = true, // variadic
+ .memcpy = false,
+ .memset = false,
+ .memmove = false,
+ .min = true, // variadic
+ .wasm_memory_size = false,
+ .wasm_memory_grow = false,
+ .mod = true,
+ .mul_with_overflow = true,
+ .panic = false,
+ .pop_count = true,
+ .prefetch = false,
+ .ptr_cast = true,
+ .int_from_ptr = true,
+ .rem = true,
+ .return_address = true, // no parameters
+ .select = false,
+ .set_eval_branch_quota = true,
+ .set_float_mode = true,
+ .set_runtime_safety = true,
+ .shl_exact = false,
+ .shl_with_overflow = false,
+ .shr_exact = false,
+ .shuffle = false,
+ .size_of = true,
+ .splat = true,
+ .reduce = false,
+ .src = true, // no parameters
+ .sqrt = true,
+ .sin = true,
+ .cos = true,
+ .tan = true,
+ .exp = true,
+ .exp2 = true,
+ .log = true,
+ .log2 = true,
+ .log10 = true,
+ .abs = true,
+ .floor = true,
+ .ceil = true,
+ .trunc = true,
+ .round = true,
+ .sub_with_overflow = true,
+ .tag_name = true,
+ .This = true, // no parameters
+ .trap = true, // no parameters
+ .truncate = true,
+ .EnumLiteral = true, // no parameters
+ .Int = true,
+ .Tuple = true,
+ .Pointer = false,
+ .Fn = false,
+ .Struct = false,
+ .Union = false,
+ .Enum = false,
+ .type_info = true,
+ .type_name = true,
+ .TypeOf = true, // variadic
+ .union_init = false,
+ .Vector = false,
+ .volatile_cast = true,
+ .work_item_id = false,
+ .work_group_size = false,
+ .work_group_id = false,
+});
pub const InlayHint = struct {
index: usize,
@@ -492,8 +501,9 @@ fn writeNodeInlayHint(
=> {
if (!builder.config.inlay_hints_show_parameter_name or !builder.config.inlay_hints_show_builtin) return;
- const name = tree.tokenSlice(tree.nodeMainToken(node));
- if (name.len < 2 or excluded_builtins_set.has(name[1..])) return;
+ const name = offsets.tokenToSlice(tree, tree.nodeMainToken(node));
+ const item = std.zig.BuiltinFn.list.get(name) orelse return;
+ if (excluded_builtins_set.get(item.tag)) return;
var buffer: [2]Ast.Node.Index = undefined;
const params = tree.builtinCallParams(&buffer, node).?;
From 75e0b965e4ecbaab08bd72630f7e59ef77654923 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Thu, 16 Apr 2026 13:10:13 +0200
Subject: [PATCH 12/14] nix: replace 'mitchellh/zig-overlay' with
'silversquirl/zig-flake'
---
flake.nix | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/flake.nix b/flake.nix
index 9ee4393d4..b6a85ff90 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,14 +2,14 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
- zig-overlay.url = "github:mitchellh/zig-overlay";
- zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
+ zig-flake.url = "github:silversquirl/zig-flake";
+ zig-flake.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
- zig-overlay,
+ zig-flake,
}: let
lib = nixpkgs.lib;
parseVersionFieldFromZon = name:
@@ -33,7 +33,7 @@
system: let
pkgs = nixpkgs.legacyPackages.${system};
fs = lib.fileset;
- zig = zig-overlay.packages.${system}.master;
+ zig = zig-flake.packages.${system}.nightly;
target = builtins.replaceStrings ["darwin"] ["macos"] system;
in {
formatter.${system} = pkgs.alejandra;
From e59e84150d1f28606920e3718e9082b5505a5310 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Thu, 16 Apr 2026 12:52:39 +0200
Subject: [PATCH 13/14] nix: pin Zig version based on minimum_zig_version field
in zon file
The upside is that this change prevents ZLS from failing to build when
the zig-flake has been overriden by the dependant flake. The downside is
that this masks runtime incompatibilities between Zig and ZLS.
---
flake.nix | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/flake.nix b/flake.nix
index b6a85ff90..e3f2bf72f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -18,6 +18,7 @@
(builtins.match ".*\n[[:space:]]*\\.${name}[[:space:]]=[[:space:]]\"([^\"]+)\".*")
builtins.head
];
+ minimum_zig_version = parseVersionFieldFromZon "minimum_zig_version";
zlsVersionShort = parseVersionFieldFromZon "version";
zlsVersionFull =
zlsVersionShort
@@ -33,7 +34,12 @@
system: let
pkgs = nixpkgs.legacyPackages.${system};
fs = lib.fileset;
- zig = zig-flake.packages.${system}.nightly;
+ zigVersion = lib.pipe minimum_zig_version [
+ builtins.splitVersion
+ (lib.sublist 0 5)
+ (lib.concatStringsSep "_")
+ ];
+ zig = zig-flake.packages.${system}."zig_${zigVersion}";
target = builtins.replaceStrings ["darwin"] ["macos"] system;
in {
formatter.${system} = pkgs.alejandra;
From 872e5fc02a607d4687ca48a0735d88ab889aba25 Mon Sep 17 00:00:00 2001
From: Techatrix
Date: Thu, 16 Apr 2026 13:17:17 +0200
Subject: [PATCH 14/14] flake.lock: Update
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Flake lock file updates:
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/4e92bbcdb030f3b4782be4751dc08e6b6cb6ccf2?narHash=sha256-OEf7YqhF9IjJFYZJyuhAypgU%2BVsRB5lD4DuiMws5Ltc%3D' (2026-04-07)
→ 'github:NixOS/nixpkgs/7e495b747b51f95ae15e74377c5ce1fe69c1765f?narHash=sha256-B35lpsqnSZwn1Lmz06BpwF7atPgFmUgw1l8KAV3zpVQ%3D' (2026-04-13)
• Added input 'zig-flake':
'github:silversquirl/zig-flake/2c9eec04c4a27ca54addd9e6c28a5a64906cba0a?narHash=sha256-lmTMKC0Rc0L1GChNEAkn%2BhV/iaFMU4B2C9NkQqydumo%3D' (2026-04-14)
• Added input 'zig-flake/nixpkgs':
follows 'nixpkgs'
• Removed input 'zig-overlay'
• Removed input 'zig-overlay/flake-compat'
• Removed input 'zig-overlay/nixpkgs'
• Removed input 'zig-overlay/systems'
---
flake.lock | 60 ++++++++++++------------------------------------------
1 file changed, 13 insertions(+), 47 deletions(-)
diff --git a/flake.lock b/flake.lock
index 60812d934..16c79fb1b 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,28 +1,12 @@
{
"nodes": {
- "flake-compat": {
- "flake": false,
- "locked": {
- "lastModified": 1696426674,
- "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
- "owner": "edolstra",
- "repo": "flake-compat",
- "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
- "type": "github"
- },
- "original": {
- "owner": "edolstra",
- "repo": "flake-compat",
- "type": "github"
- }
- },
"nixpkgs": {
"locked": {
- "lastModified": 1775595990,
- "narHash": "sha256-OEf7YqhF9IjJFYZJyuhAypgU+VsRB5lD4DuiMws5Ltc=",
+ "lastModified": 1776067740,
+ "narHash": "sha256-B35lpsqnSZwn1Lmz06BpwF7atPgFmUgw1l8KAV3zpVQ=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "4e92bbcdb030f3b4782be4751dc08e6b6cb6ccf2",
+ "rev": "7e495b747b51f95ae15e74377c5ce1fe69c1765f",
"type": "github"
},
"original": {
@@ -35,44 +19,26 @@
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
- "zig-overlay": "zig-overlay"
- }
- },
- "systems": {
- "flake": false,
- "locked": {
- "lastModified": 1681028828,
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
- "owner": "nix-systems",
- "repo": "default",
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
- "type": "github"
- },
- "original": {
- "owner": "nix-systems",
- "repo": "default",
- "type": "github"
+ "zig-flake": "zig-flake"
}
},
- "zig-overlay": {
+ "zig-flake": {
"inputs": {
- "flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
- ],
- "systems": "systems"
+ ]
},
"locked": {
- "lastModified": 1775651458,
- "narHash": "sha256-Vin1+HI1TJvBXS4d3rcflfCWL9MmJJjjoZ2ATsPHAqg=",
- "owner": "mitchellh",
- "repo": "zig-overlay",
- "rev": "e9ed260913d18b2973a86eabc8e46642c4e04c75",
+ "lastModified": 1776183664,
+ "narHash": "sha256-lmTMKC0Rc0L1GChNEAkn+hV/iaFMU4B2C9NkQqydumo=",
+ "owner": "silversquirl",
+ "repo": "zig-flake",
+ "rev": "2c9eec04c4a27ca54addd9e6c28a5a64906cba0a",
"type": "github"
},
"original": {
- "owner": "mitchellh",
- "repo": "zig-overlay",
+ "owner": "silversquirl",
+ "repo": "zig-flake",
"type": "github"
}
}
|