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

[Bug] Struct-typed pattern-local variables behave unexpectedly #2137

Open
1 task
PathogenDavid opened this issue Feb 24, 2025 · 0 comments
Open
1 task

[Bug] Struct-typed pattern-local variables behave unexpectedly #2137

PathogenDavid opened this issue Feb 24, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@PathogenDavid
Copy link

Operating System

Windows

What's the issue you encountered?

When a struct is used for a pattern-local variable, all fields of the struct appear to have the value of the first field.

How can the issue be reproduced?

Create a new file (or open a random one, doesn't matter) and execute the following pattern:

import std.io;

struct Test
{
    u32 a;
    u32 b;
};

fn get_test()
{
    Test ret;
    ret.a = 100;
    ret.b = 200;
    std::print("get_test returning {}, {}", ret.a, ret.b); // Always prints 100, 200 as expected
    return ret;
};

Test t = get_test();
std::print("Global variable: {}, {}", t.a, t.b); // Prints 100, 200 as expected

struct Pattern
{
    Test tt = get_test();
    std::print("Pattern local variable: {}, {}", tt.a, tt.b); // Prints 100, 100, which is not expected
};

Pattern p @ 0;

Expected behavior: All printed messages say 100, 200

Actual behavior: The pattern-local variable test prints 100, 100

ImHex Version

1.37.1

ImHex Build Type

  • Nightly or built from sources

Installation type

MSI

Additional context?

Also reproduced on 1.35.4.

@PathogenDavid PathogenDavid added the bug Something isn't working label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant