winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.03k stars 198 forks source link

Compiler panic when trying to `bring cloud` twice #1624

Closed eladb closed 1 year ago

eladb commented 1 year ago

Community Note

Please vote by adding a 👍 reaction to the issue to help us prioritize. If you are interested to work on this issue, please leave a comment.

I tried this:

bring cloud;
bring cloud;

I expected this:

Some reasonable diagnostics

Instead, this happened:

Command failed: wing compile /Users/eladb/playground/wingly5/task-list-example.w -t sim -o /var/folders/vm/cm444l3124j_vh_8rkhz6kqm0000gn/T/wing-app-target-dir-tB1O5q
thread '' panicked at 'called `Result::unwrap()` on an `Err` value: TypeError { message: "Symbol \"cloud\" already defined in this scope", span: WingSpan { start: Point { row: 2, column: 6 }, end: Point { row: 2, column: 11 }, start_byte: 20, end_byte: 25, file_id: "task-list-example.w" } }', libs/wingc/src/type_check/jsii_importer.rs:789:14
stack backtrace:
wasm://wasm/00876982:1

RuntimeError: unreachable
at std::panicking::rust_panic_with_hook::hc5c73bd02fe928d4 (wasm://wasm/00876982:wasm-function[185]:0xae2cd)
at core::panicking::panic_fmt::h1024bc10a158814e (wasm://wasm/00876982:wasm-function[1150]:0x14fd53)
at core::result::unwrap_failed::h4f10a8b6d25baa65 (wasm://wasm/00876982:wasm-function[914]:0x1441cf)
at wingc::type_check::TypeChecker::add_module_to_env::h476e535dc3890050 (wasm://wasm/00876982:wasm-function[143]:0x9ded7)
at wingc::type_check::TypeChecker::type_check_scope::h224caa87aa329702 (wasm://wasm/00876982:wasm-function[325]:0xd7bf9)
at wingc::type_check::h5c6924d394a13c52 (wasm://wasm/00876982:wasm-function[88]:0x82f36)
at wingc_compile (wasm://wasm/00876982:wasm-function[156]:0xa35f3)
at wingc_compile.command_export (wasm://wasm/00876982:wasm-function[1284]:0x152a2a)
at Object.invoke (/Users/eladb/.volta/tools/image/packages/winglang/lib/node_modules/winglang/dist/wingc.js:74:37)
at Command.compile (/Users/eladb/.volta/tools/image/packages/winglang/lib/node_modules/winglang/dist/commands/compile.js:84:40)

Node.js v18.12.1

Component:

Compiler

Wing Version:

No response

Node.js Version:

No response

Platform(s):

No response

Anything else?

No response

staycoolcall911 commented 1 year ago

Let's generalize this - we should probably add a simple mechanism to prevent any duplicated imports and fail nicely instead of panic.

monadabot commented 1 year ago

Congrats! :rocket: This was released in Wing 0.15.3.