Repository navigation
Conversation
Float keys emit a deprecation and resource keys a warning, which an error handler can turn into an exception. Share one key mask in zend_may_throw_ex() so ASSIGN_DIM, INIT_ARRAY, ADD_ARRAY_ELEMENT, FETCH_DIM_W/FETCH_LIST_W, ARRAY_KEY_EXISTS, FETCH_DIM_IS and ISSET_ISEMPTY_DIM_OBJ agree.
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.
Float keys that lose precision (
1.5,1e20) emit a deprecation and resource keys emit a warning. An error handler can turn either into an exception.zend_may_throw_ex()decides whether a key type can throw, and each array-key opcode has its own copy of that list. The copies drifted apart. Before this change:✓ means
zend_may_throw_ex()already counts that key type as possibly throwing; ✗ means it doesn't. After the change, every row is ✓ in both columns. Array and object keys aren't listed because every row already counted them.When it wrongly answers "cannot throw":
$a[1.5] = 1;is removed, so the error handler never runs.GH-16396 reported the DCE case and was closed as intended optimizer behavior. However, these opcodes already treat resource keys as throwing, although they only emit a warning. A float key only emits a deprecation, so leaving it out is an oversight, not a policy. b33e3eb8c2d already added float keys for FETCH_DIM_IS and ISSET_ISEMPTY_DIM_OBJ. The JIT case was not discussed in GH-16396.
One shared
MAY_BE_THROWING_KEYmask replaces the seven separate lists, so they cannot drift again. A follow-up for PHP-8.5 addsMAY_BE_NULLfor the null offset deprecation.