compiler/sem/semcomptime

  Source   Edit

Implements checks for whether otherwise valid code can be run at compile time or in NimScript contexts.

Procs

proc check(n: PNode): PNode {....raises: [], tags: [].}
Given the constant-folded AST n of a freestanding expression/statement, looks for access of locals that aren't available in the current compile- time context. Example:
var x = 0
const y = x # <- 'x' cannot be used here

If such illegal access is found, the first offending node is returned, 'nil' otherwise.

  Source   Edit