fix: support class constants in defined() - #967
Conversation
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Greptile SummaryThis PR extends literal
Confidence Score: 4/5The PR is not yet safe to merge because equivalent trait constants can still be rejected when equality requires resolving a named or scoped constant rather than folding literal arithmetic. The previous equivalent-constant finding is only partially fixed:
|
| Filename | Overview |
|---|---|
| src/types/defined.rs | Implements scope-aware class-like constant existence checks, relative-scope validation, inheritance, interfaces, enum cases, and PHP casing rules. |
| src/ir_lower/expr/scoped_values.rs | Adds runtime called-class dispatch for literal defined('static::CONST') probes. |
| src/ir_lower/expr/closures.rs | Captures the called-class identifier in class-scope closures so late-static behavior survives method return. |
| src/codegen_support/runtime/callables/closure_bind.rs | Extends closure binding to validate and copy descriptors containing the hidden called-class capture across all supported targets. |
| src/types/traits/merge.rs | Composes trait constants and compares duplicate values after standalone folding, but the previous equivalent-value finding remains only partly fixed. |
| tests/codegen/oop/constants.rs | Adds broad regression coverage for class-like defined() behavior, visibility, late-static dispatch, traits, enums, and invalid scopes. |
Reviews (9): Last reviewed commit: "fix: compare folded trait constant value..." | Re-trigger Greptile
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
|
Greptile P1 disposition after PHP 8.5 and compiler-path verification:
Current HEAD: |
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
|
Follow-up for the residual Greptile 4/5 (named/scoped trait const equality before compare): #1007 |
Summary
defined('Class::CONST')names through class, interface, trait-imported, and enum metadata instead of the global-constant table aloneself::/parent::, named arguments, and runtime-called-classstatic::behaviorClosure::bind,bindTo, andcallon every supported targetErrors for invalid relative scopes and markdefined()as potentially throwing so exception optimization preserves handlersVerification
cargo test --test codegen_tests test_defined_literal(10 passed)cargo test --test codegen_tests closure_bind(22 passed)cargo buildRemaining limit
defined()names remain outside this AOT lookupFixes #752
Fixes #1005
Fixes #1006