Skip to content

Fix parsing of enum key: allow absolute paths and fix value instances#310

Open
Mingun wants to merge 14 commits intokaitai-io:masterfrom
Mingun:fix-absolute-enums
Open

Fix parsing of enum key: allow absolute paths and fix value instances#310
Mingun wants to merge 14 commits intokaitai-io:masterfrom
Mingun:fix-absolute-enums

Conversation

@Mingun
Copy link
Contributor

@Mingun Mingun commented Oct 4, 2024

Closes kaitai-io/kaitai_struct#857.

This PR started as support for the ability to use absolute paths (which is actually supported by type resolver) and ended as a bug fix for a known issue.

It is based on #309, because I do not want to do the work twice and check that the type resolution works as expected (it was already checked in the base PR).

The same names makes it difficult to recognize where which function is used even with help from IDE
Also make some functions private to not pollute public namespace. The other methods will be tested
so cannot be made private because it creates difficulties to test them
…ssage is a type name

Especially when the type name is something very generic, like 'test'
Error text does not checked yet, because it will be changed and even those tests
which passed now, would fail due to that

Failures (12):

[info] ClassTypeProvider$Test:
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:287)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:324)
[info]   - doesn't resolve 'two::one' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:336)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:361)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:398)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:435)
[info]   - doesn't resolve 'two::one' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:447)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:472)
[info]   - doesn't resolve 'two::one' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:484)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:509)
[info]   - doesn't resolve 'one::two' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:546)
[info]   - doesn't resolve 'two::one' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.TypeNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:558)
Error text does not checked yet, because it will be changed and even those tests
which passed now, would fail due to that

Failures (6):

[info] ClassTypeProvider$Test:
[info]   - doesn't resolve 'one::e' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.EnumNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:690)
[info]   - doesn't resolve 'one::e' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.EnumNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:740)
[info]   - doesn't resolve 'one::e' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.EnumNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:765)
[info]   - doesn't resolve 'one::e' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.EnumNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:790)
[info]   - doesn't resolve 'one::e' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.EnumNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:815)
[info]   - doesn't resolve 'one::e' *** FAILED ***
[info]     Expected exception io.kaitai.struct.precompile.EnumNotFoundError to be thrown, but no exception was thrown (ClassTypeProvider$Test.scala:840)
This commit also unify enum resolution in expression language and in `enum` keys

Fixes kaitai-io/kaitai_struct#1028
This commit also unify type resolution in expression language and in `type` keys

Fixes kaitai-io/kaitai_struct#786
It not so big and this unifies handling of types and enums
@Mingun Mingun force-pushed the fix-absolute-enums branch from 420d877 to 42380b9 Compare December 24, 2025 14:25
Mingun added a commit to Mingun/kaitai_struct_tests that referenced this pull request Dec 25, 2025
@Mingun Mingun force-pushed the fix-absolute-enums branch from 42380b9 to 577b15b Compare December 25, 2025 12:32
Because of new types type system enforses fixing kaitai-io/kaitai_struct#857

This test need to be updated:

[info] - expr_compare_enum2 *** FAILED ***
[info]   [expr_compare_enum2.ksy: /seq/1/if:
[info]          error: can't compare EnumType(EnumRef(false,List(),animal),Int1Type(false)) and Int1Type(true)
[info]   ]
[info]     did not equal
[info]   [expr_compare_enum2.ksy: /seq/1/if:
[info]          error: can't compare EnumType(List(animal),Int1Type(false)) and Int1Type(true)
[info]   ] (SimpleMatchers.scala:34)
@Mingun Mingun force-pushed the fix-absolute-enums branch from 577b15b to 78654f1 Compare December 25, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to find Enum in Instance when Imported

1 participant