How do I use verbose or debug compilation modes?

← Debugging and Troubleshooting · Ref: Q252

EK9 provides a comprehensive set of command-line flags for controlling compilation verbosity, debugging, and output.

ERROR VERBOSITY (-E0 through -E4)

  -E0    Minimal: single-line error messages with location and code
  -E1    Visual: Rust-style display with source snippets and caret markers
  -E2    Suggestions: visual plus 'Did you mean?' fuzzy matching
  -E3    Full: detailed explanations with diagnosis, rationale, and examples
  -E4    Developer: internal compiler diagnostics for compiler developers

Default is -E1. Use -E3 when learning EK9 or when an error is confusing.

COMPILATION MODES

  -c     Incremental compile (only recompile changed files)
  -C     Full recompile (recompile everything from scratch)
  -r     Compile and run the program
  -t     Run tests (@Test methods and expected_output.txt)

Incremental compilation is faster for large projects. Use -C when you suspect stale cached output.

DEBUG AND VERBOSE FLAGS

  -v     Verbose output: shows which files are being compiled and which phases complete
  -dv    Debug verbose: more detail including symbol resolution and phase timing
  -cg    Debug instrumentation: embeds source location (file:line:column) in assertion messages and stack traces
  -cd    Combined development and debug mode

The -cg flag is essential for meaningful assertion failure messages. Without it, assertion failures show generic text. With it, they show exact source locations.

ANALYSIS FLAGS

  -di    DI/AOP analysis: outputs dependency injection wiring and aspect pointcut information
  -Cp N  Stop at phase N: compiles up to the specified phase number and stops. Not typical for end users, but valuable for AI tools learning EK9 (verify syntax and types compile correctly without generating runnable programs) and for compiler developers

HELP AND INFORMATION

  -h keyword    Help for a built-in type (e.g., 'ek9 -h String', 'ek9 -h List')
  -h EXXXXX     Explain a specific error code
  -H            List all available help keywords
  -V            Show compiler version

TEST OUTPUT FORMATS

  -t0    Plain text test output
  -t1    JUnit XML output
  -t2    TAP format
  -t3    JSON output
  -t4    Markdown output
  -t5    CSV output
  -t6    HTML dashboard

The default is -t0 (plain text). Use -t1 for CI/CD integration.

COVERAGE

  -tc SET      Statement coverage tracking
  -tc COUNT    Execution count per statement
  -tc ATOMIC   Thread-safe execution counting

Coverage data is written to a coverage report. The default threshold is 80%.

See Q246 for debugging strategies. See Q247 for reading error messages. See Q253 for understanding compiler phases. See Q323 for AI quality workflow. See Q622 for formatting flags. See Q627 for profiling flags.

Example

defines module qa.debugging.verbosemodes

  defines function

    describeFeature()
      ->
        featureEnabled as Boolean
        featureName as String
      <- description as String: String()

      if featureEnabled
        description: `${featureName} is enabled`
      else
        description: `${featureName} is disabled`

  defines program

    VerboseModesDemo()
      stdout <- Stdout()

      // Simple program to demonstrate compilation
      stdout.println("Compilation modes demo")

      // Use string interpolation
      version <- "1.0"
      stdout.println(`Version: ${version}`)

      // Simple arithmetic
      a <- 10
      b <- 20
      stdout.println(`Sum: ${a + b}`)

      // Boolean check via function parameter
      stdout.println(describeFeature(true, "Logging"))

      // List operations
      items <- ["alpha", "beta", "gamma"]
      for item in items
        stdout.println(`Item: ${item}`)

Common mistakes

E08090 — If 'featureDesc' is declared but never used anywhere, the compiler rejects it as unused. Every variable must be referenced. See ek9 -h E08090 for details.

Incorrect:

featureDesc <- describeFeature(true, "Logging")

Correct:

stdout.println(describeFeature(true, "Logging"))
Other ways to ask this
  • What compiler flags does EK9 support?
  • How do I get more detail from the EK9 compiler?
  • What are the EK9 compilation modes?

Coming from another language?

Java: javac has minimal flags, IDEs provide most analysis. Python: python -v for verbose, -W for warnings, no compilation phases. Rust: RUST_LOG for verbose, cargo build --verbose, rustc --explain. Go: go build -v for verbose, go vet for analysis. C++: compiler-specific flags (-Wall, -Wextra, -g for debug info). Kotlin: kotlinc has minimal flags, relies on IDE. EK9: five error verbosity levels, debug instrumentation, phase-level control, built-in test formats, coverage modes, offline error code lookup.

Keywords: cg, instrumentation, compile, flag, migrate, troubleshoot, phase, mode, test, error-message, coverage, output, E0, E1, E2, E3, verbose, debug