fixes #836
This commit is contained in:
parent
32ec5af60a
commit
abb2c21047
2 changed files with 20 additions and 0 deletions
|
|
@ -242,6 +242,9 @@ proc concreteType(c: TCandidate, t: PType): PType =
|
||||||
addSonSkipIntLit(result, t.sons[1]) # XXX: semantic checking for the type?
|
addSonSkipIntLit(result, t.sons[1]) # XXX: semantic checking for the type?
|
||||||
of tyNil:
|
of tyNil:
|
||||||
result = nil # what should it be?
|
result = nil # what should it be?
|
||||||
|
of tySequence, tySet:
|
||||||
|
if t.sons[0].kind == tyEmpty: result = nil
|
||||||
|
else: result = t
|
||||||
of tyGenericParam, tyAnything:
|
of tyGenericParam, tyAnything:
|
||||||
result = t
|
result = t
|
||||||
while true:
|
while true:
|
||||||
|
|
|
||||||
17
tests/generics/tcannot_pass_empty_seq_to_generic.nim
Normal file
17
tests/generics/tcannot_pass_empty_seq_to_generic.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "type mismatch: got (seq[empty])"
|
||||||
|
line: 16
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #836
|
||||||
|
|
||||||
|
type
|
||||||
|
TOption*[T] = object
|
||||||
|
case FIsSome: bool
|
||||||
|
of false: nil
|
||||||
|
of true: FData: T
|
||||||
|
|
||||||
|
proc some*[T](value: T): TOption[T] = TOption[T](FIsSome: true, FData: value)
|
||||||
|
|
||||||
|
echo some(@[]).FIsSome
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue