src/lint/private/semanalysis

Search:
Group by:
Source   Edit  

Per-file semantic analysis. Each result owns an independent compiler context.

Types

SemDiagnostic = object
  file*: string
  line*, col*: int
  message*: string
  severity*: lineinfos.Severity
A compiler error from configuration loading or semantic analysis, or a backend error such as an unreadable input file. Not a lint finding: severity is the compiler's classification, independent of check settings. The location refers to the compiler-reported file, which may be a dependency; file is empty when no location is available. Source   Edit  
SemResult = ref object
  tree*: PNode
  diagnostics*: seq[SemDiagnostic]
Retained compiler context and best-effort typed tree. The outcome of analyzing one entry file and its import dependencies. Retains compiler state so the tree's symbols and types remain usable. Diagnostics do not imply the tree is absent: it may be partial after errors, or nil when analysis could not produce a tree. Source   Edit  

Procs

proc analyzeFile(path: string; onDiagnostic: proc (diagnostic: SemDiagnostic) {.
    closure, ...gcsafe.} = nil): SemResult {.
    ...raises: [Exception, ValueError, OSError, KeyError, Exception], tags: [
    ReadDirEffect, RootEffect, ReadEnvEffect, ReadIOEffect, ExecIOEffect,
    WriteIOEffect, WriteDirEffect, WriteEnvEffect, TimeEffect], forbids: [].}
Analyzes an entry file with Nim's configuration and recursive imports. Returns diagnostics and any retained typed tree, including partial results. Calls onDiagnostic as errors arrive, before any direct compiler termination. Source   Edit