summary refs log tree commit diff stats
path: root/.github/workflows/ci_publish.yml
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-09-04 20:36:45 +0800
committerGitHub <noreply@github.com>2023-09-04 14:36:45 +0200
commitd13aab50cf465a7f2edf9c37a4fa30e128892e72 (patch)
tree042c3f6fce69a3dfebfaa088a5ca7c924bdb4ec6 /.github/workflows/ci_publish.yml
parentc5495f40d5d881e6bd155c9e6c9c6e5e49b749a7 (diff)
downloadNim-d13aab50cf465a7f2edf9c37a4fa30e128892e72.tar.gz
fixes branches interacting with break, raise etc. in strictdefs (#22627)
```nim
{.experimental: "strictdefs".}

type Test = object
  id: int

proc test(): Test =
  if true:
    return Test()
  else:
    return
echo test()
```

I will tackle https://github.com/nim-lang/Nim/issues/16735 and #21615 in
the following PR.


The old code just premises that in branches ended with returns, raise
statements etc. , all variables including the result variable are
initialized for that branch. It's true for noreturn statements. But it
is false for the result variable in a branch tailing with a return
statement, in which the result variable is not initialized. The solution
is not perfect for usages below branch statements with the result
variable uninitialized, but it should suffice for now, which gives a
proper warning.

It also fixes

```nim

{.experimental: "strictdefs".}

type Test = object
  id: int

proc foo {.noreturn.} = discard

proc test9(x: bool): Test =
  if x:
    foo()
  else:
    foo()
```
which gives a warning, but shouldn't
Diffstat (limited to '.github/workflows/ci_publish.yml')
0 files changed, 0 insertions, 0 deletions