Skip to content

Panic compiling static::X class constant access #336

@nahime0

Description

@nahime0

Description

static::X inside a static method should resolve via late static binding, but the current compiler panics during codegen instead of compiling the program or producing a diagnostic.

Minimal reproduction

<?php
class A { const X = 'A'; public static function show() { echo static::X; } }
class B extends A { const X = 'B'; }
B::show();

Steps to reproduce

  1. Save the program as main.php.
  2. Run php main.php.
  3. Compile with elephc: target/debug/elephc main.php.

Expected behavior

PHP 8.4 prints:

B

Elephc should either match PHP or emit a normal unsupported-feature diagnostic. It should not panic.

Actual behavior

Compilation aborts with a Rust panic:

thread 'main' panicked at src/codegen/expr/objects.rs:480:10:
ScopedConstantAccess on `static` not supported yet

Environment

  • elephc 0.23.5
  • PHP 8.4.19
  • macOS arm64
  • reproduced on 2026-06-05

Notes

This is a compiler crash, not just a semantic mismatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions