Skip to content

Language: runtime __LINE__ magic constant on include stack (#85 remainder) #715

@PurHur

Description

@PurHur

Problem

#707 shipped runtime __DIR__ / __FILE__ on the include stack (VM ScriptStack, JIT per-unit path). docs/capabilities-syntax.md still lists __LINE__ as no — logging, asserts, and error pages in multi-file apps need the line of the currently executing script, not only parse-time folding.

examples/003-MiniWebApp does not require __LINE__ for v1, but the umbrella #85 remains open until this slice lands.

Scope

Mode Behavior
VM __LINE__ reflects current script on include stack (push/pop with TYPE_INCLUDE)
JIT Per-compile-unit line table or runtime opcode (match VM)
AOT Compile-time constant OK for single-file; document when bundled sources fold

Implementation hints

Step Files Notes
VM stack lib/VM.php Extend script stack pushed on TYPE_INCLUDE with line from Runtime::parse()
Compiler lib/Compiler.php Expr_MagicConst / TYPE_MAGIC_LINE (mirror #707 TYPE_MAGIC_DIR)
JIT lib/JIT.php Per-block line from php-cfg getLine() at magic site
Lint lib/Lint/UnsupportedRegistry.php Remove block when runtime path green
Docs script/capability-syntax-lib.php Flip __LINE__ row to yes (#706 generator)

Acceptance criteria

./script/ci-fast.sh --filter magic_line
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./script/ci-fast.sh --filter magic_line
  • test/compliance/cases/language/magic_line_include.phpt — helper returns __LINE__; main includes it
  • php script/capability-syntax.php --check passes after row update

Dependencies

Verification

Local/Docker only — not GitHub Actions.

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions