dfinity / motoko

Simple high-level language for writing Internet Computer canisters
Apache License 2.0
515 stars 97 forks source link

Motoko Compiler Bug(?) #4378

Open bittoko opened 9 months ago

bittoko commented 9 months ago

I failed to deploy a canister in my local environment.

Might be worth noting that I deploy a similar canister last night just fine but when I got onto my laptop today I started getting compiler errors in VSCode. The first word in every file was flagged with an error that said "Unexpected error while compiling Motoko file."

Here is the output that DFX told me to report:

Stderr: OOPS! You've triggered a compiler bug. Please report this at https://github.com/dfinity/motoko/issues/new with the following details:

Motoko 0.10.4 (source bdwn2hfm-w488d075-sq5qmvns-2djspvqx)

Fatal error: exception Invalid_argument("Type.as_obj") Raised at Mo_typesType.invalid in file "mo_types/type.ml", line 587, characters 16-54 Called from Mo_frontendCoverage.match_pat in file "mo_frontend/coverage.ml", line 212, characters 17-39 Called from Mo_frontendCoverage.check_cases in file "mo_frontend/coverage.ml", line 369, characters 20-71 Called from Mo_frontend__Coverage.check_pat in file "mo_frontend/coverage.ml", line 379, characters 4-80 Called from Mo_frontendTyping.coverage' in file "mo_frontend/typing.ml", line 186, characters 29-34 Called from Mo_frontendTyping.coverage_pat in file "mo_frontend/typing.ml" (inlined), line 199, characters 2-69 Called from Mo_frontendTyping.check_pat_exhaustive in file "mo_frontend/typing.ml", line 1988, characters 4-38 Called from Mo_frontendTyping.infer_dec_valdecs in file "mo_frontend/typing.ml", line 2709, characters 16-92 Called from Mo_frontend__Typing.infer_block_valdecs.(fun) in file "mo_frontend/typing.ml", line 2675, characters 19-44 Called from Stdliblist.fold_left in file "list.ml", line 121, characters 24-34 Called from Mo_frontendTyping.infer_block_valdecs in file "mo_frontend/typing.ml", line 2674, characters 4-166 Called from Mo_frontendTyping.infer_block in file "mo_frontend/typing.ml", line 2361, characters 14-42 Called from Mo_frontendTyping.check_lib.(fun) in file "mo_frontend/typing.ml", line 2804, characters 23-59 Called from Mo_frontend__Typing.recover_opt.(fun) in file "mo_frontend/typing.ml", line 79, characters 55-60 Called from Mo_frontendTyping.recover_with in file "mo_frontend/typing.ml", line 78, characters 56-59 Called from Diag.with_message_store in file "lang_utils/diag.ml", line 82, characters 10-13 Called from Pipeline.check_lib in file "pipeline/pipeline.ml", line 215, characters 16-41 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 386, characters 22-41 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Pipeline.chase_imports.go in file "pipeline/pipeline.ml", line 384, characters 18-37 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "langutils/diag.ml", line 32, characters 27-30 Called from Diag.traverse in file "lang_utils/diag.ml", line 48, characters 20-25 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Pipeline.chase_imports.go_set in file "pipeline/pipeline.ml" (inlined), line 415, characters 20-42 Called from Pipeline.chase_imports in file "pipeline/pipeline.ml", line 417, characters 47-63 Called from Pipeline.load_progs in file "pipeline/pipeline.ml", line 425, characters 21-52 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30 Called from Pipeline.compile_files in file "pipeline/pipeline.ml", line 724, characters 27-71 Called from DuneexeMoc.process_files in file "exes/moc.ml", line 240, characters 49-94 Called from DuneexeMoc in file "exes/moc.ml", line 337, characters 4-23

ggreif commented 9 months ago

Thanks for the report! We'll try to reproduce the problem, but I suspect that without a (stripped-down) test case this will be rather time intensive. Can you by chance provide a short extract of the code that you are compiling that exhibits the crash? I suspect it is some pattern match in an actor { ... } or object { ... } block.

Also, do you happen to get some diagnostic output from the type checker? Maybe your program is not type-correct?

bittoko commented 9 months ago

Hi @ggreif. I apologize for taking so long to respond. The truth is I made the mistake of writing a whole mess of different libraries and then tried to bring them together in a canister. So I’ve been trying to separate them and test individually until I can reproduce the problem. Haven’t been able to recreate yet.

Would you like me close this issue and open a new one if/when I’m able to provide a better example?