mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
fixes #22932 follow up https://github.com/nim-lang/Nim/pull/21629 --------- Co-authored-by: Nickolay Bukreyev <SirNickolas@users.noreply.github.com>
This commit is contained in:
@@ -82,7 +82,7 @@ when defined(nimPreviewSlimSystem):
|
||||
|
||||
when (NimMajor, NimMinor) >= (1, 1):
|
||||
type
|
||||
SomePointer = ref | ptr | pointer | proc
|
||||
SomePointer = ref | ptr | pointer | proc | iterator {.closure.}
|
||||
else:
|
||||
type
|
||||
SomePointer = ref | ptr | pointer
|
||||
@@ -90,7 +90,7 @@ else:
|
||||
type
|
||||
Option*[T] = object
|
||||
## An optional type that may or may not contain a value of type `T`.
|
||||
## When `T` is a a pointer type (`ptr`, `pointer`, `ref` or `proc`),
|
||||
## When `T` is a a pointer type (`ptr`, `pointer`, `ref`, `proc` or `iterator {.closure.}`),
|
||||
## `none(T)` is represented as `nil`.
|
||||
when T is SomePointer:
|
||||
val: T
|
||||
|
||||
@@ -196,6 +196,12 @@ proc main() =
|
||||
doAssert x.isNone
|
||||
doAssert $x == "none(cstring)"
|
||||
|
||||
|
||||
static: main()
|
||||
main()
|
||||
|
||||
when not defined(js):
|
||||
block: # bug #22932
|
||||
var it = iterator: int {.closure.} = discard
|
||||
doAssert it.option.isSome # Passes.
|
||||
it = nil
|
||||
doAssert it.option.isNone # Passes.
|
||||
|
||||
Reference in New Issue
Block a user