Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch expression value type error. #1374

Open
VladiStep opened this issue May 7, 2023 · 1 comment · May be fixed by #1689
Open

switch expression value type error. #1374

VladiStep opened this issue May 7, 2023 · 1 comment · May be fixed by #1689
Labels
bug Something isn't working decompiler Problems with the decompiler

Comments

@VladiStep
Copy link
Member

Describe the bug

The decompiler doesn't parse all the case values type, only the first one.
Here's an example: case fnt_main:, but case 2:

switch myfont
{
    case fnt_main:
        if (ascciChar < 1025 || myletter == "Ә" || myletter == "ә")
            letterx += spacing
        else
            letterx += (string_width(myletter) + 3)
        break
    case 2:
        if (ascciChar < 1025 || myletter == "Ә" || myletter == "ә")
            letterx += spacing
        else
            letterx += (string_width(myletter) + 1)
        break
    case 4:
        if (ascciChar < 1025 || myletter == "Ә" || myletter == "ә")
            letterx += spacing
        else
            letterx += string_width(myletter)
        break
...

Reproducing steps

  1. Use switch in code.

Setup Details

  1. UTMT version - a712808
@Jacky720
Copy link
Contributor

Jacky720 commented Feb 22, 2024

It appears this is because switch blocks are processed in reverse order (at least for type propagation) such that every case except the first is being compared to an untyped tempvar instead of the actual switch comparison. My best ideas for first steps at a fix would be to somehow fast-track the tempvar parsing or to try a second pass of the type propagation after high-level decompilation.

@Jacky720 Jacky720 linked a pull request Feb 22, 2024 that will close this issue
@Miepee Miepee added the decompiler Problems with the decompiler label Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working decompiler Problems with the decompiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants