-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorerror messageThis issue points out an error message that is unhelpful and should be improved.This issue points out an error message that is unhelpful and should be improved.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
Zig Version
0.12.0-dev.25+36c57c3ba
Steps to Reproduce and Observed Behavior
test {
const x = struct {
fn x(sentinel: u8) void {
var buf: [64]u8 = undefined;
_ = @import("std").mem.sliceTo(&buf, sentinel);
}
}.x;
x(0);
}This fails to detect that sentinel is a runtime-known argument and cannot be passed to comptime parameter comptime end: meta.Elem(@TypeOf(ptr)) of std.mem.sliceTo:
$ zig test x.zig
Segmentation fault (core dumped)
It works when making sentinel a comptime parameter.
Expected Behavior
$ zig test x.zig
x.zig:7:31: error: runtime-known argument passed to comptime parameter
_ = @import("std").mem.sliceTo(&buf, sentinel);
^~~~~~~~
x.zig:13:39: note: declared comptime here
pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) {
^~~
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorerror messageThis issue points out an error message that is unhelpful and should be improved.This issue points out an error message that is unhelpful and should be improved.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.