VM/JIT: runtime __DIR__ and __FILE__ on include stack (#707)#709
Merged
Conversation
Resolve __DIR__/__FILE__ at runtime from the executing script path instead of baking dirname at parse time only. Push/pop ScriptStack on TYPE_INCLUDE, add TYPE_SCRIPT_MAGIC opcode, and extend ConstStringFolder for lint folding. Closes #707. Documents rows in capabilities-syntax (#706). Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TYPE_SCRIPT_MAGICso__DIR__/__FILE__resolve from the current script path (VMScriptStackpush/pop onTYPE_INCLUDE; JIT uses per-unitBlock::scriptPath()).MagicScriptConstCFG expr instead of compile-time dirname literals.ConstStringFolderto fold__DIR__ . '/literal'for lint when preprocessor clears concatoriginal.magic_dir_nested(+ JIT variant); capabilities-syntax rows for Docs: capabilities-syntax rows for __DIR__, __FILE__, __LINE__ (#85) #706.Test plan
php bin/vm.php test/compliance/cases/language/magic_dir_nested/entry.phpConstStringFolderTest,IncludeLiteralTest,CapabilitySyntaxTest(Docker)./script/ci-local.sh --filter magic_dir_nested(full gate on merge host)Closes #707. Closes #706.
Made with Cursor