I feel I fundamentally don't understand something about Nim, or that the code
in my editor is not actually the code that is executed.
What I'm trying to achieve is an "early return pattern", where a proc exits if
some precondition is not met. In this case the Option value `gid` should be
present. So initially I had the two commented lines enabled. To recover my
sanity I tried the "always return" logic.
In the sample below, vscode marks all lines below the return statement with
warnings of unreachable code. When I run this code and place a breakpoint at
the last line however, that last line is reached. What's more, is that in the
debug Watches, `gid` is displayed as `{val:0, has:false}` and `isNone` is `true`
What could be going on here?
proc loadGid(level: Level, obj: LevelObjectEntity) =
let isNone = obj.gid.isNone
# if isNone:
# return
return
let gid = obj.gid.get
[..] more lines
Run