Skip to content

Conversation

@sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Aug 2, 2025

Problem

In specific cases, loop-value failed to convert to the expected type due to a loss of converter info that lead to simplification ultimately determining that it only needed an Object -> Object converter, which is effectively return this. This lead to issues like #8108 where the name of loop-value could not be determined due to an ItemStack being returned, which is not AnyNamed, rather than the ItemStack being converted to AnyNamed via ItemType.

Solution

The problem stemmed from ExprLoopValue#getConvertedExpression, which had a special implementation that at one point was probably useful? It effectively just made a dynamic converter using Converters.convert to attempt each possible to type in order.

Sharp-eyed viewers may note this as being what ConvertedExpression#newInstance does during init, so really it's just a runtime call to CE#newInstance, if we're matching high level behavior. However, it results in a CE that thinks it's just a simple Object->Object converter and doesn't actually know what it's supposed to be doing, leading to the loss of info mentioned previously.

Replacing this special converter with CE#newInstance results in the expected ConvertedExpression being formed, with CInfos to each of the possible return types, and all the necessary information retained. This also makes the condition in ELV#gCE() useless, since the super impl is just CE#newInstance, so the whole method can be and was removed.

Testing Completed

Added a new regression test based on the code provided in #8108.

Supporting Information


Completes: #8108
Related: none

@sovdeeth sovdeeth requested a review from a team as a code owner August 2, 2025 23:21
@sovdeeth sovdeeth added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Aug 2, 2025
@sovdeeth sovdeeth requested review from Absolutionism and erenkarakal and removed request for a team August 2, 2025 23:21
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Aug 2, 2025
@sovdeeth sovdeeth linked an issue Aug 2, 2025 that may be closed by this pull request
1 task
@sovdeeth sovdeeth moved this to In Review in 2.12 Releases Aug 2, 2025
@github-project-automation github-project-automation bot moved this from In Review to Awaiting Merge in 2.12 Releases Aug 3, 2025
@skriptlang-automation skriptlang-automation bot added patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. and removed needs reviews A PR that needs additional reviews labels Aug 3, 2025
@APickledWalrus APickledWalrus merged commit 077ff62 into SkriptLang:dev/patch Aug 7, 2025
5 checks passed
@skriptlang-automation skriptlang-automation bot added the completed The issue has been fully resolved and the change will be in the next Skript update. label Aug 7, 2025
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done - Awaiting Release in 2.12 Releases Aug 7, 2025
@skriptlang-automation skriptlang-automation bot removed the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Aug 7, 2025
@Absolutionism Absolutionism moved this from Done - Awaiting Release to Done - Released in 2.12 Releases Sep 2, 2025
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update.

Projects

No open projects
Status: Done - Released

Development

Successfully merging this pull request may close these issues.

Name of item from variable

5 participants