Skip to content

Conversation

@Mingun
Copy link
Contributor

@Mingun Mingun commented Oct 5, 2024

The test

# expr_bad_id_inst_value.ksy: /instances/foo/value:
# 	error: invalid ID: 'BAD', expected /^[a-z][a-z0-9_]*$/
#
meta:
  id: expr_bad_id_inst_value
instances:
  foo:
    value: BAD

Fixes test which instead of reporting error shows this exception:

[info] - expr_bad_id_inst_value *** FAILED ***
[info]   io.kaitai.struct.format.InvalidIdentifier: invalid ID: 'BAD', expected /^[a-z][a-z0-9_]*$/
[info]   at io.kaitai.struct.format.Identifier$.checkIdentifier(Identifier.scala:52)
[info]   at io.kaitai.struct.format.InstanceIdentifier.<init>(Identifier.scala:113)
[info]   at io.kaitai.struct.ClassTypeProvider.resolveMember(ClassTypeProvider.scala:83)
[info]   at io.kaitai.struct.ClassTypeProvider.determineType(ClassTypeProvider.scala:46)
[info]   at io.kaitai.struct.ClassTypeProvider.determineType(ClassTypeProvider.scala:20)
[info]   at io.kaitai.struct.translators.TypeDetector.detectTypeRaw(TypeDetector.scala:61)
[info]   at io.kaitai.struct.translators.TypeDetector.detectType(TypeDetector.scala:25)
[info]   at io.kaitai.struct.precompile.ValueTypesDeriver.$anonfun$deriveValueType$2(ValueTypesDeriver.scala:28)
[info]   at io.kaitai.struct.precompile.ValueTypesDeriver.$anonfun$deriveValueType$2$adapted(ValueTypesDeriver.scala:21)
[info]   at scala.collection.immutable.RedBlackTree$.foreach(RedBlackTree.scala:291)
[info]   ...

Actually, I think, that this is incorrect test. You should check attribute IDs when you defines attribute, not when you use it. Obviously, you use that name with which attribute is defined. I expect, that this test will report unknown attribute BAD even when it is obviously violates ID requirements

Fixes test which instead of reporting error shows this exception:

[info] - expr_bad_id_inst_value *** FAILED ***
[info]   io.kaitai.struct.format.InvalidIdentifier: invalid ID: 'BAD', expected /^[a-z][a-z0-9_]*$/
[info]   at io.kaitai.struct.format.Identifier$.checkIdentifier(Identifier.scala:52)
[info]   at io.kaitai.struct.format.InstanceIdentifier.<init>(Identifier.scala:113)
[info]   at io.kaitai.struct.ClassTypeProvider.resolveMember(ClassTypeProvider.scala:83)
[info]   at io.kaitai.struct.ClassTypeProvider.determineType(ClassTypeProvider.scala:46)
[info]   at io.kaitai.struct.ClassTypeProvider.determineType(ClassTypeProvider.scala:20)
[info]   at io.kaitai.struct.translators.TypeDetector.detectTypeRaw(TypeDetector.scala:61)
[info]   at io.kaitai.struct.translators.TypeDetector.detectType(TypeDetector.scala:25)
[info]   at io.kaitai.struct.precompile.ValueTypesDeriver.$anonfun$deriveValueType$2(ValueTypesDeriver.scala:28)
[info]   at io.kaitai.struct.precompile.ValueTypesDeriver.$anonfun$deriveValueType$2$adapted(ValueTypesDeriver.scala:21)
[info]   at scala.collection.immutable.RedBlackTree$.foreach(RedBlackTree.scala:291)
[info]   ...
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.

1 participant