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>
This commit is contained in:
committed by
Veikka Tuominen
parent
da95da438e
commit
ae8d26a6a0
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user