Skip to content

Emitter crash array of set (frontend rejects these) / array of dyn (frontend rejects these) on Array.from({length}, () => new Set()) #182

Description

@xXCrash2BomberXx

Array.from({ length: N }, () => new Set()) crashes the backend emitter with an uncaught exception rather than a diagnostic. The thrown message ("frontend rejects these") says the frontend is supposed to reject this construct before it reaches codegen — so this is the frontend's rejection guard failing to fire, not a feature request for array-of-Set support.

Minimal Demo

const arr = Array.from({ length: 2 }, () => new Set());
console.log(arr.length);

Output

file://[...]/moon/node_modules/@scriptc/compiler/dist/backend/emission/emit-types.js:531
            throw new Error(`emitter bug: array of ${elem.kind} (frontend rejects these)`);
                  ^

Error: emitter bug: array of dyn (frontend rejects these)
    at elemKindC (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emit-types.js:531:19)
    at arrNewC (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emit-shapes.js:528:31)
    at CEmitter.arrNewC (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emitter.js:1230:16)
    at emitExpr (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emit-exprs.js:1114:45)
    at CEmitter.emitExpr (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emitter.js:1834:16)
    at emitStmt (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emit-stmts.js:189:25)
    at CEmitter.emitStmt (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emitter.js:1717:16)
    at emitStmts (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emit-stmts.js:139:11)
    at CEmitter.emitStmts (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emitter.js:1714:16)
    at emitFunction (file://[...]/node_modules/@scriptc/compiler/dist/backend/emission/emit-stmts.js:64:7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions