Files
Nim/compiler
ringabout 73e661d01b 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.
2023-08-08 21:12:54 +08:00
..
2023-08-06 14:26:21 +02:00
2022-09-27 10:57:47 +02:00
2017-01-07 22:35:09 +01:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-05-06 21:27:28 +02:00
2023-08-06 14:26:21 +02:00
2021-01-12 09:36:51 +01:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2022-03-23 20:34:53 +01:00
2023-08-06 14:26:21 +02:00
2023-07-02 22:36:05 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00
2023-08-06 14:26:21 +02:00

Nim Compiler

  • This directory contains the Nim compiler written in Nim.
  • Note that this code has been translated from a bootstrapping version written in Pascal.
  • So the code is not a poster child of good Nim code.

See Internals of the Nim Compiler for more information.