results: work around void member codegen issue (#150)
This commit is contained in:
parent
989047dd76
commit
8a1b6ab4dc
|
@ -304,11 +304,35 @@ type
|
||||||
## https://github.com/nim-lang/Nim/issues/13879 - double-zero-init slow
|
## https://github.com/nim-lang/Nim/issues/13879 - double-zero-init slow
|
||||||
## https://github.com/nim-lang/Nim/issues/14318 - generic error raises pragma
|
## https://github.com/nim-lang/Nim/issues/14318 - generic error raises pragma
|
||||||
|
|
||||||
case o: bool
|
# TODO https://github.com/nim-lang/Nim/issues/20699
|
||||||
of false:
|
# case o: bool
|
||||||
e: E
|
# of false:
|
||||||
of true:
|
# e: E
|
||||||
v: T
|
# of true:
|
||||||
|
# v: T
|
||||||
|
|
||||||
|
when T is void:
|
||||||
|
when E is void:
|
||||||
|
o: bool
|
||||||
|
else:
|
||||||
|
case o: bool
|
||||||
|
of false:
|
||||||
|
e: E
|
||||||
|
of true:
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
when E is void:
|
||||||
|
case o: bool
|
||||||
|
of false:
|
||||||
|
discard
|
||||||
|
of true:
|
||||||
|
v: T
|
||||||
|
else:
|
||||||
|
case o: bool
|
||||||
|
of false:
|
||||||
|
e: E
|
||||||
|
of true:
|
||||||
|
v: T
|
||||||
|
|
||||||
Opt*[T] = Result[T, void]
|
Opt*[T] = Result[T, void]
|
||||||
|
|
||||||
|
|
|
@ -403,3 +403,15 @@ block: # Experiments
|
||||||
counter2 += 1
|
counter2 += 1
|
||||||
|
|
||||||
doAssert counter2 == 1, "one-item collection when set"
|
doAssert counter2 == 1, "one-item collection when set"
|
||||||
|
|
||||||
|
block: # Constants
|
||||||
|
# TODO https://github.com/nim-lang/Nim/issues/20699
|
||||||
|
type
|
||||||
|
WithOpt = object
|
||||||
|
opt: Opt[int]
|
||||||
|
const
|
||||||
|
noneWithOpt =
|
||||||
|
WithOpt(opt: Opt.none(int))
|
||||||
|
proc checkIt(v: WithOpt) =
|
||||||
|
doAssert v.opt.isNone()
|
||||||
|
checkIt(noneWithOpt)
|
||||||
|
|
Loading…
Reference in New Issue