Skip to content

Commit

Permalink
Fix missing checks that args match top-level params
Browse files Browse the repository at this point in the history
Fixes kaitai-io/kaitai_struct#1086

Until now, top-level types were treated the same as opaque types, which
had the unintended consequence that arguments passed to top-level types
were not validated against the number and data types of declared
parameters.

This commit fixes the `formats_err` tests added in
kaitai-io/kaitai_struct_tests@9d518e6 -
more specifically, these failures in `sbt test` output are now fixed:

```
- params_call_bad_type_top_import *** FAILED ***
  []
    did not equal
  [params_call_bad_type_top_import.ksy: /seq/0/type:
  	error: can't pass argument #1 of type CalcFloatType into parameter `has_trailer` of type CalcBooleanType
  ] (SimpleMatchers.scala:34)
- params_call_bad_type_top_local *** FAILED ***
  []
    did not equal
  [params_call_bad_type_top_local.ksy: /seq/0/type:
  	error: can't pass argument #1 of type CalcFloatType into parameter `has_trailer` of type CalcBooleanType
  ] (SimpleMatchers.scala:34)
- params_call_too_many_top_import *** FAILED ***
  []
    did not equal
  [params_call_too_many_top_import.ksy: /seq/0/type:
  	error: parameter count mismatch: 2 declared, but 3 used
  ] (SimpleMatchers.scala:34)
- params_call_too_many_top_local *** FAILED ***
  []
    did not equal
  [params_call_too_many_top_local.ksy: /seq/0/type:
  	error: parameter count mismatch: 2 declared, but 3 used
  ] (SimpleMatchers.scala:34)
```
  • Loading branch information
generalmimon committed Apr 7, 2024
1 parent b2ec9e5 commit a03420c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ object DataType {
classSpec.get.isExternal(curClass)
def isOpaque = {
val cs = classSpec.get
cs.isTopLevel || cs.meta.isOpaque
cs.meta.isOpaque
}
}
case class UserTypeInstream(
Expand Down

0 comments on commit a03420c

Please sign in to comment.