kaitai_struct_compiler icon indicating copy to clipboard operation
kaitai_struct_compiler copied to clipboard

Fix non-exhaustive warnings with the Ast.expr.Call node

Open Mingun opened this issue 3 years ago • 1 comments

Because function pointers are forbidden in the expression language from now parser won't allow anymore following constructions:

  • 42()
  • "string"()
  • true()
  • (...)()
  • []()

This PR fixes those warnings (3):

[warn] /home/runner/work/kaitai_struct_compiler/kaitai_struct_compiler/compiler/shared/src/main/scala/io/kaitai/struct/GraphvizClassCompiler.scala:319:24: Exhaustivity analysis reached max recursion depth, not all missing cases are reported.
[warn] (Please try with scalac -Ypatmat-exhaust-depth 40 or -Ypatmat-exhaust-depth off.)
[warn]         val fromFunc = func match {
[warn]                        ^
[warn] /home/runner/work/kaitai_struct_compiler/kaitai_struct_compiler/compiler/shared/src/main/scala/io/kaitai/struct/GraphvizClassCompiler.scala:319:24: Exhaustivity analysis reached max recursion depth, not all missing cases are reported.
[warn] (Please try with scalac -Ypatmat-exhaust-depth 40 or -Ypatmat-exhaust-depth off.)
[warn]         val fromFunc = func match {
[warn]                        ^
[warn] /home/runner/work/kaitai_struct_compiler/kaitai_struct_compiler/compiler/shared/src/main/scala/io/kaitai/struct/translators/CommonMethods.scala:192:5: Exhaustivity analysis reached max recursion depth, not all missing cases are reported.
[warn] (Please try with scalac -Ypatmat-exhaust-depth 40 or -Ypatmat-exhaust-depth off.)
[warn]     func match {
[warn]     ^

Strangely, but it seems that some code are compiled twice, because you can notice identical warnings, for example GraphvizClassCompiler.scala:319:24.

Somehow it introduces 3 new warnings, but it seems that there have a limit on count of warnings from compiler (!?):

  • This warning is duplication of another warning:
    [warn] /home/runner/work/kaitai_struct_compiler/kaitai_struct_compiler/compiler/shared/src/main/scala/io/kaitai/struct/languages/RustCompiler.scala:142:17: unreachable code
    [warn]         out.puts(s"     stream: ${kaitaiType2NativeType(attrType)},")
    [warn]                 ^
    
  • That warnings seems to be new just because. I have no idea why they appeared, they seems unrelated to changes:
    [warn] /home/runner/work/kaitai_struct_compiler/kaitai_struct_compiler/compiler/shared/src/main/scala/io/kaitai/struct/translators/CppTranslator.scala:106:24: match may not be exhaustive.
    [warn] It would fail on the following input: SharedPointers
    [warn]       config.cppConfig.pointers match {
    [warn]                        ^
    [warn] /home/runner/work/kaitai_struct_compiler/kaitai_struct_compiler/compiler/shared/src/main/scala/io/kaitai/struct/translators/ExpressionValidator.scala:28:5: Exhaustivity analysis reached max recursion depth, not all missing cases are reported.
    [warn] (Please try with scalac -Ypatmat-exhaust-depth 40 or -Ypatmat-exhaust-depth off.)
    [warn]     v match {
    [warn]     ^
    

Mingun avatar Dec 01 '20 19:12 Mingun

@GreyCat, @generalmimon, I see that you have some activity in the project recently. Could you find a time to review my PRs, for example, this?

Mingun avatar Mar 08 '24 06:03 Mingun