mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-26 04:45:08 +00:00
fixes #836
This commit is contained in:
@@ -242,6 +242,9 @@ proc concreteType(c: TCandidate, t: PType): PType =
|
||||
addSonSkipIntLit(result, t.sons[1]) # XXX: semantic checking for the type?
|
||||
of tyNil:
|
||||
result = nil # what should it be?
|
||||
of tySequence, tySet:
|
||||
if t.sons[0].kind == tyEmpty: result = nil
|
||||
else: result = t
|
||||
of tyGenericParam, tyAnything:
|
||||
result = t
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user