You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
passing @[] to seq[string] or OtherType gives a cgen error.
I use the following pattern as a very convenient way to have a compile time Option[T] type, however it doesn't work with T = seq[string] when passing @[]
Example 1
whentrue: # gitissue D20201026T002034:hereprocfn(a =4, b: seq[string] ortuple[] = ()) =discard# eg: when b is tuple[]: ...fn(1)
fn(1, @[""])
var a: seq[string] =@[]
fn(1, a)
fn(1, seq[string](@[]))
fn(1, @[]) # BUG: error: conflicting types for 'fn__d58I39cH9a6bcpi3QDPJ5dBA'
Current Output
@mt11189.nim.c:354:31: error: conflicting types for 'fn__d58I39cH9a6bcpi3QDPJ5dBA'
Expected Output
works
Example 2
likewise with {} for set:
whentrue: # gitissue D20201026T002034procfn(a =4, b: set[uint8] ortuple[] = ()) =discard# eg: when b is tuple[]: ...fn(1)
fn(1, {1'u8})
var a: set[uint8] = {}
fn(1, a)
fn(1, set[uint8]({}))
fn(1, {}) # BUG: internal error: invalid kind for lastOrd(tyEmpty)
The text was updated successfully, but these errors were encountered:
timotheecour
changed the title
cgen error when passing @[] to seq[string] or OtherType,
cgen error when passing @[] to seq[string] or OtherTypeOct 25, 2020
timotheecour
changed the title
cgen error when passing @[] to seq[string] or OtherType
cgen or internal error when passing @[] to seq[string] or T (ditto with {} and set[uint8])
Oct 25, 2020
seq[empty] matches seq[string] or T because it matches seq[string], but compiler cannot figure out how to convert seq[empty] to seq[string] or T so it stays as seq[empty], causes codegen error (confirm with echo typeof(b)). Kind of like #1214
metagn
added a commit
to metagn/Nim
that referenced
this issue
Oct 2, 2024
passing
@[]
toseq[string] or OtherType
gives a cgen error.I use the following pattern as a very convenient way to have a compile time
Option[T]
type, however it doesn't work withT = seq[string]
when passing@[]
Example 1
Current Output
@mt11189.nim.c:354:31: error: conflicting types for 'fn__d58I39cH9a6bcpi3QDPJ5dBA'
Expected Output
works
Example 2
likewise with
{}
for set:Additional Information
devel 1.5.1 2265955
see also #15722
The text was updated successfully, but these errors were encountered: