-
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Reduced example (from the comment below):
proc hello(): int {.discardable.} = 12 iterator test(): int {.closure.} = while true: yield 12 hello() let t = testOriginal issue:
A very strange error appears when I use the SDL2 library (https://github.com/nim-lang/sdl2):
Error: internal error: yield in expr not lowered No stack traceback available To create a stacktrace, rerun compilation with ./koch temp c <file> Here's how it appears:
method setText*(edittext: EditTextRef, text: cstring) {.async.} = ## Redraws the EditText's text. ## ## If text is empty, then draws hint with hint color. ## ## Arguments: ## - ``text`` -- new text. if text.len == 0: edittext.text = text edittext.background.fillRect(nil, 0x00000000) blitSurface(edittext.saved_background, nil, edittext.background, nil) var rendered = edittext.font.renderUtf8BlendedWrapped( edittext.hint, await parseColor(edittext.hint_color.int), 1024) var rect = rect(edittext.x, edittext.y, rendered.w, rendered.h) # The error appears due to the line below blitSurface(rendered, nil, edittext.background, rect.addr) else: await procCall edittext.TextViewRef.setText(text)How do I fix this error?
add discard after error line
method setText*(edittext: EditTextRef, text: cstring) {.async.} = ## Redraws the EditText's text. ## ## If text is empty, then draws hint with hint color. ## ## Arguments: ## - ``text`` -- new text. if text.len == 0: edittext.text = text edittext.background.fillRect(nil, 0x00000000) blitSurface(edittext.saved_background, nil, edittext.background, nil) var rendered = edittext.font.renderUtf8BlendedWrapped( edittext.hint, await parseColor(edittext.hint_color.int), 1024) var rect = rect(edittext.x, edittext.y, rendered.w, rendered.h) blitSurface(rendered, nil, edittext.background, rect.addr) # When I add discard - the error disappears discard else: await procCall edittext.TextViewRef.setText(text)How do I run the code?
nim c -r -d: release --showAllMismatches: on --hints: off --threads: on -d: ssl: on --opt: speed FILE.nim
OS: Windows, x64
Nim version: 1.0.6
Full code here: https://github.com/Ethosa/yukiko