mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-19 15:31:28 +00:00
fixes #22932
follow up https://github.com/nim-lang/Nim/pull/21629
---------
Co-authored-by: Nickolay Bukreyev <SirNickolas@users.noreply.github.com>
(cherry picked from commit 0dc3513613)
This commit is contained in:
@@ -81,7 +81,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
|
||||
@@ -89,7 +89,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