summary refs log tree commit diff stats
path: root/tests/parallel/tdeepcopy.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-08-08 21:12:54 +0800
committerGitHub <noreply@github.com>2023-08-08 21:12:54 +0800
commit73e661d01bdde815a5f388b960cd4d0593f7accc (patch)
treedb614b5094b8d95a2e113e04b5840640d1b0a7be /tests/parallel/tdeepcopy.nim
parent10a6e4c236b8d4d609a07b29ad5b7b4e517cd367 (diff)
downloadNim-73e661d01bdde815a5f388b960cd4d0593f7accc.tar.gz
modernize compiler/reorder, which exposes yet another strictdefs bug (#22415)
```nim
{.experimental: "strictdefs".}

type
  NodeKind = enum
    nkImportStmt
    nkStmtList
    nkNone

  PNode = ref object
    kind: NodeKind

proc hasImportStmt(n: PNode): bool =
  # Checks if the node is an import statement or
  # i it contains one
  case n.kind
  of nkImportStmt:
    return true
  of nkStmtList:
    if false:
      return true
  else:
    result = false

var n = PNode()
echo hasImportStmt(n)
```
It compiles without warnings, but shouldn't. As a contrast, 

```nim
{.experimental: "strictdefs".}

type
  NodeKind = enum
    nkImportStmt
    nkStmtList
    nkNone

  PNode = ref object
    kind: NodeKind

proc hasImportStmt(n: PNode): bool =
  # Checks if the node is an import statement or
  # i it contains one
  case n.kind
  of nkImportStmt:
    result = true
  of nkStmtList:
    if false:
      return true
  else:
    result = false

var n = PNode()
echo hasImportStmt(n)
```
This gives a proper warning.
Diffstat (limited to 'tests/parallel/tdeepcopy.nim')
0 files changed, 0 insertions, 0 deletions