diff options
| author | antlilja <liljaanton2001@gmail.com> | 2022-08-06 22:32:00 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-08-27 11:17:48 +0300 |
| commit | ae8d26a6a00a528bdf555689c2a93cb35a3287f2 (patch) | |
| tree | d72b651523e62b81d0b1733cf2f1a4eced7265db /lib/std | |
| parent | da95da438ed5c934a9f42811651f5ffa524e48a8 (diff) | |
| download | zig-ae8d26a6a00a528bdf555689c2a93cb35a3287f2.tar.gz zig-ae8d26a6a00a528bdf555689c2a93cb35a3287f2.zip | |
Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.
Co-authored-by: Veikka Tuominen <git@vexu.eu>
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/c.zig | 2 | ||||
| -rw-r--r-- | lib/std/elf.zig | 4 | ||||
| -rw-r--r-- | lib/std/io/bit_reader.zig | 2 | ||||
| -rw-r--r-- | lib/std/io/bit_writer.zig | 2 | ||||
| -rw-r--r-- | lib/std/meta.zig | 2 | ||||
| -rw-r--r-- | lib/std/multi_array_list.zig | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/c.zig b/lib/std/c.zig index f01f580083..7b018f62d5 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -20,7 +20,7 @@ pub const Tokenizer = tokenizer.Tokenizer; /// If linking gnu libc (glibc), the `ok` value will be true if the target /// version is greater than or equal to `glibc_version`. /// If linking a libc other than these, returns `false`. -pub fn versionCheck(glibc_version: std.builtin.Version) type { +pub fn versionCheck(comptime glibc_version: std.builtin.Version) type { return struct { pub const ok = blk: { if (!builtin.link_libc) break :blk false; diff --git a/lib/std/elf.zig b/lib/std/elf.zig index cc43e11a7d..4a9b7a498f 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -406,7 +406,7 @@ pub const Header = struct { } }; -pub fn ProgramHeaderIterator(ParseSource: anytype) type { +pub fn ProgramHeaderIterator(comptime ParseSource: anytype) type { return struct { elf_header: Header, parse_source: ParseSource, @@ -456,7 +456,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type { }; } -pub fn SectionHeaderIterator(ParseSource: anytype) type { +pub fn SectionHeaderIterator(comptime ParseSource: anytype) type { return struct { elf_header: Header, parse_source: ParseSource, diff --git a/lib/std/io/bit_reader.zig b/lib/std/io/bit_reader.zig index 15262f67a2..e897850b83 100644 --- a/lib/std/io/bit_reader.zig +++ b/lib/std/io/bit_reader.zig @@ -7,7 +7,7 @@ const meta = std.meta; const math = std.math; /// Creates a stream which allows for reading bit fields from another stream -pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type { +pub fn BitReader(comptime endian: std.builtin.Endian, comptime ReaderType: type) type { return struct { forward_reader: ReaderType, bit_buffer: u7, diff --git a/lib/std/io/bit_writer.zig b/lib/std/io/bit_writer.zig index d71afe5fe5..0be2e7ab08 100644 --- a/lib/std/io/bit_writer.zig +++ b/lib/std/io/bit_writer.zig @@ -7,7 +7,7 @@ const meta = std.meta; const math = std.math; /// Creates a stream which allows for writing bit fields to another stream -pub fn BitWriter(endian: std.builtin.Endian, comptime WriterType: type) type { +pub fn BitWriter(comptime endian: std.builtin.Endian, comptime WriterType: type) type { return struct { forward_writer: WriterType, bit_buffer: u8, diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 937b1998ff..7e64eff49f 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -764,7 +764,7 @@ const TagPayloadType = TagPayload; ///Given a tagged union type, and an enum, return the type of the union /// field corresponding to the enum tag. -pub fn TagPayload(comptime U: type, tag: Tag(U)) type { +pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { comptime debug.assert(trait.is(.Union)(U)); const info = @typeInfo(U).Union; diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 48dddf636d..11aec707ab 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -459,7 +459,7 @@ pub fn MultiArrayList(comptime S: type) type { return self.bytes[0..capacityInBytes(self.capacity)]; } - fn FieldType(field: Field) type { + fn FieldType(comptime field: Field) type { return meta.fieldInfo(S, field).field_type; } |
