003 conditional imports

✓ Passing This code compiles and runs correctly.

Code

// Test conditional imports with annotations
//
// This test verifies that conditional imports are DEADSTRIPPED when their
// flags are not set. Since we run without --profile, --test, or --debug flags,
// all conditional imports below should be completely absent from the AST.
//
// The unconditional import should be parsed normally.

// Unconditional import (baseline) - should appear in AST
~import "$std/compiler"

// Conditional imports - should NOT appear in AST (deadstripped)
~[profile]import "$std/profiler"

~[test]import "$std/testing"

~[debug|trace]import "$std/debug"

~event hello {}
| done {}
input.kz

Expected AST

{
  "module_annotations": [],
  "items": [
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 1,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 2,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 3,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 4,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 5,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 6,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 7,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 9,
        "col": 0
      }
    },
    {
      "type": "import_decl",
      "path": "$std/compiler",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 11,
        "col": 0
      }
    },
    {
      "type": "host_line",
      "module": "input",
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 12,
        "col": 0
      }
    },
    {
      "type": "event_decl",
      "name": "hello",
      "path": [
        "hello"
      ],
      "module": "input",
      "input": {
        "fields": []
      },
      "branches": [
        {
          "name": "done",
          "payload": {
            "fields": []
          }
        }
      ],
      "location": {
        "file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/210_003_conditional_imports/input.kz",
        "line": 21,
        "col": 0
      }
    }
  ]
}

Test Configuration

PARSER_TEST