Closed PgBiel closed 4 months ago
The code below
import gleam/io pub const class = 5 pub const oh_dear = class pub fn main() { io.println("Hello from mongus!") }
compiles to
import * as $io from "../gleam_stdlib/gleam/io.mjs"; export function main() { return $io.println("Hello from mongus!"); } export const class$ = 5; export const oh_dear = class;
which errors at runtime with
export const oh_dear = class; ^ SyntaxError: Unexpected token ';' at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:167:18) at callTranslator (node:internal/modules/esm/loader:285:14) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:30) Node.js v20.11.1
due to a missing call to maybe_escape_identifier_doc at
maybe_escape_identifier_doc
https://github.com/gleam-lang/gleam/blob/99c50dde27f6146a8dbbd6963a74a7dd4fa70ee3/compiler-core/src/javascript/expression.rs#L1289
Turns out the line immediately below is also missing an escape, leading to mismatching import and export.
https://github.com/gleam-lang/gleam/blob/99c50dde27f6146a8dbbd6963a74a7dd4fa70ee3/compiler-core/src/javascript/expression.rs#L1290
Here as well (this one was hard to find):
https://github.com/gleam-lang/gleam/blob/99c50dde27f6146a8dbbd6963a74a7dd4fa70ee3/compiler-core/src/javascript/expression.rs#L1233
The code below
compiles to
which errors at runtime with
due to a missing call to
maybe_escape_identifier_doc
athttps://github.com/gleam-lang/gleam/blob/99c50dde27f6146a8dbbd6963a74a7dd4fa70ee3/compiler-core/src/javascript/expression.rs#L1289