Issue 1:
Stack unwind:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', cli/fmt_errors.rs:211:45
stack backtrace:
0: 0x55d18d4104a3 - std::backtrace_rs::backtrace::libunwind::trace::h72c2fb8038f1bbee
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
1: 0x55d18d4104a3 - std::backtrace_rs::backtrace::trace_unsynchronized::h1e3b084883f1e78c
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/mod.rs:66
2: 0x55d18d4104a3 - std::sys_common::backtrace::_print_fmt::h3bf6a7ebf7f0394a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:79
3: 0x55d18d4104a3 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2e8cb764b7fe02e7
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:58
4: 0x55d18cf5ca3c - core::fmt::write::h7a1184eaee6a8644
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
5: 0x55d18d40fc91 - std::io::Write::write_fmt::haeeb374d93a67eac
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/io/mod.rs:1516
6: 0x55d18d40f595 - std::sys_common::backtrace::_print::h1d14a7f6ad632dc8
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:61
7: 0x55d18d40f595 - std::sys_common::backtrace::print::h301abac8bb2e3e81
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:48
8: 0x55d18d40f595 - std::panicking::default_hook::{{closure}}::hde0cb80358a6920a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:208
9: 0x55d18d40f595 - std::panicking::default_hook::h9b1a691049a0ec8f
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:227
10: 0x55d18d40f595 - std::panicking::rust_panic_with_hook::h2bdec87b60580584
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:577
11: 0x55d18d4296a8 - std::panicking::begin_panic_handler::{{closure}}::h101ca09d9df5db47
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484
12: 0x55d18d429674 - std::sys_common::backtrace::__rust_end_short_backtrace::h3bb85654c20113ca
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153
13: 0x55d18d42962d - rust_begin_unwind
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
14: 0x55d18cf5a030 - core::panicking::panic_fmt::h48c31e1e3d550146
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
15: 0x55d18cf59e4c - core::panicking::panic::h184ede6dd822ffb4
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:50
16: 0x55d18cd4de67 - core::option::Option<T>::unwrap::h00128de0aadcc2ac
17: 0x55d18ceb7db4 - <deno::fmt_errors::PrettyJsError as core::fmt::Display>::fmt::h60dcb48dfb5fb3f0
18: 0x55d18cf5ca3c - core::fmt::write::h7a1184eaee6a8644
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
19: 0x55d18cf620d3 - core::fmt::Formatter::write_fmt::h610a3b7429e5462e
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1509
20: 0x55d18cf20718 - anyhow::error::<impl core::fmt::Display for anyhow::Error>::fmt::h908d2c3d7f1d9f3c
21: 0x55d18cf5ca3c - core::fmt::write::h7a1184eaee6a8644
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
22: 0x55d18cf620d3 - core::fmt::Formatter::write_fmt::h610a3b7429e5462e
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1509
23: 0x55d18cf20718 - anyhow::error::<impl core::fmt::Display for anyhow::Error>::fmt::h908d2c3d7f1d9f3c
24: 0x55d18cf5ca3c - core::fmt::write::h7a1184eaee6a8644
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
25: 0x55d18d3f4764 - core::fmt::Write::write_fmt::h076b1b3611776a3c
26: 0x55d18cd2a558 - <T as alloc::string::ToString>::to_string::hfaf68a090b8ed610
27: 0x55d18cf02f60 - deno::main::ha2d27aa65e12940b
28: 0x55d18cd2286a - std::sys_common::backtrace::__rust_begin_short_backtrace::h9a5cc0e9c63a2e26
29: 0x55d18cf112c2 - main
30: 0x7fdfde1a3bf7 - __libc_start_main
31: 0x55d18ccc04ba - _start
32: 0x0 - <unknown>

Attached is the actual file that I was working on when this happened.

panic.txt

file.ts may be an empty file.

I tried to cut down the file to a minimum reproducible example, but it wasn't working without everything.

Run with --no-check, this does not occur without it.

I believe that the bad formatting is on line 37, (_, i).

Issue 2:
I'm experiencing a strange bug with Deno.

When a exception is thrown the main process panics. This is the trace:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', cli\fmt_errors.rs:86:8
stack backtrace:
0: 0x7ff7af88a45b - <unknown>
1: 0x7ff7af53cecc - <unknown>
2: 0x7ff7af889483 - <unknown>
3: 0x7ff7af888bb8 - <unknown>
4: 0x7ff7af887d2e - <unknown>
5: 0x7ff7af88efe5 - <unknown>
6: 0x7ff7af53a4b0 - <unknown>
7: 0x7ff7af53a2cc - <unknown>
8: 0x7ff7af36cbf2 - <unknown>
9: 0x7ff7af48ada8 - <unknown>
10: 0x7ff7af48b345 - <unknown>
11: 0x7ff7af53cecc - <unknown>
12: 0x7ff7af751885 - <unknown>
13: 0x7ff7af349c1d - <unknown>
14: 0x7ff7af4daf6f - <unknown>
15: 0x7ff7af8aa3f6 - <unknown>
16: 0x7ff7af4ea67e - <unknown>
17: 0x7ff7b048bf10 - CrashForExceptionInNonABICompliantCodeRange
18: 0x7ff8e9777bd4 - BaseThreadInitThunk
19: 0x7ff8ea16ce51 - RtlUserThreadStart

I don't know how to reproduce the bug but it happened in my project so I tried to isolate it in a separated branch:

https://github.com/AndreJesusBrito/WebAssembly-Language-Compiler/tree/rust-exception-bug-isolation

The bug happens in file src/SyntaxAnalysis/SyntaxRule.ts at line 25 when I throw an exception.

...
public getDerivation(terminal: string): RuleDerivation {
const derivation = this.derivations.get(terminal);
if (derivation) {
return {
derivationSymbols: [...derivation.derivationSymbols].reverse(),
actions: derivation.actions,
};
} else {
throw SyntaxError("Unexpected token '" + terminal + "' at rule " + this._name); // THIS IS LINE 25
}
}

public setDerivation(rule: SyntaxSymbol[], actions: ActionObj[], ...terminals: string[]): void {
for (const terminal of terminals) {
if (this.derivations.get(terminal) instanceof Array) {
console.warn("'" + terminal + "' repeated terminal for rule " + this._name);
...

Even though I'm using a SyntaxError (that is not a very good idea and will change later) it seems to happen for any error including the base Error class.

The most strange thing to me is that by changing the white space on this file it can work correctly.

For example, when I remove line 28 it works fine:

error: Uncaught SyntaxError: Unexpected token '' at rule none
public setDerivation(rule: SyntaxSymbol[], actions: ActionObj[], ...terminals: string[]): void {
^
at SyntaxRule.getDerivation (file:///C:/Users/Andr%C3%A9%20Brito/Documents/GitHub/WebAssembly-Language-Compiler/src/SyntaxAnalysis/SyntaxRule.ts:28:13)
at file:///C:/Users/Andr%C3%A9%20Brito/Documents/GitHub/WebAssembly-Language-Compiler/src/main.ts:4:1

I'm running using the command:

deno run src\main.ts

and my specs are:

deno 1.2.2
v8 8.5.216
typescript 3.9.2
OS: Windows_NT x64 10.0.18362

Hope this helps! :)