ImHex icon indicating copy to clipboard operation
ImHex copied to clipboard

[Bug] `#include` from std lib fails with `Unknown type` sometimes

Open squeek502 opened this issue 2 years ago • 1 comments

Operating System

Windows

What's the issue you encountered?

~~In the portable version:~~

#include <std/mem.pat>

gives the error:

error[P0003]: Unknown type
  --> <Source Code>:1:1709
1 | #include <std/mem.pat>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ^
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Type T has not been declared yet.

hint: If this type is being declared further down in the code, consider forward declaring it with 'using T;'.

~~In the non-portable version, it works as expected.~~

How can the issue be reproduced?

~~Try to #include a std lib file from within the portable version on Windows.~~

Not totally sure yet, see comment below.

ImHex Version

1.24.3

ImHex Build Type

  • [ ] Nightly or built from sources

Additional context?

No response

squeek502 avatar Oct 24 '22 23:10 squeek502

I may have misdiagnosed this. I've had this reproduce in the non-portable version as well. It seems like the Pattern editor input gets corrupted somehow and it seems to think line 1 is >= 1709 characters long but it's actually not. Haven't been able to find what exactly causes it since I had auto evaluate on but will now try to find a cause if I can reproduce it again (restarting ImHex fixes it).

EDIT: I've reproduced it again but am still unsure what caused it. I have an instance that is affected open though if there's anything I can do with it to provide more info.

Some things worth noting:

  • Once an instance is affected, there doesn't seem to be much that fixes it besides a full restart
  • Ctrl + A, delete, and then retyping the #include line still gives the same error
  • It only seems to affect #include (deleting the #include line allows the pattern to compile again)
  • Once it's affected, it doesn't matter where the #include line is, it'll still give the same error (e.g. if it's moved to line 7 it'll give error[P0003]: Unknown type --> <Source Code>:7:1709
  • The result of saving the pattern doesn't have any extra/suspicious bytes in it
    • Loading the same pattern after saving it ~~does fix the error~~. Scratch that, loading the saved pattern is not consistent at fixing it.

squeek502 avatar Oct 24 '22 23:10 squeek502

The exact same behavior happens in my machine (Arch Linux x84_64 | 6.0.6-arch1-1), tested the same ImHex version (1.24.3) (installed from the AUR)

I pretty much think it mostly happens if some specific previous syntax error occurs, because i tried with auto eval turned on/off and sometimes some errors trigger it and other times it doesn't.

  • Forgetting a ; on a struct field triggers the bug

However these don't:

  • Forgetting a ; on an instruction inside or outside a function
  • Forgetting a ; on a variable outside or inside a function

I think i triggered it somewhere else but i can't remember

OriDevTeam avatar Nov 04 '22 11:11 OriDevTeam

Hey, sorry I didn't see this issue until now. I fixed this bug a while ago but it's not yet in the latest release. Please download the latest nightly from https://imhex.werwolv.net which should work as expected. I'll put out a new release soonish too

WerWolv avatar Nov 04 '22 12:11 WerWolv