sweet-js/sweet-core

Very confusing error when not appropriately getting `value`

Closed this issue · 2 comments

Input:

syntax fun = function(ctx) {
    let param = ctx.next();
    let body = ctx.next().value.inner();
    return #`
        function(${param}) { 
            return ${body}; 
        }
    `;
}

let add = fun x { x + 1 }

Actual:

TypeError: s_924.addScope is not a function

Expected:
Some error about needing to get the value out of the generator return value or something related to the actual problem instead of this addScope thing

Or at least displaying the value of s_924?

The object that caused the error to be thrown is now shown

Error: Unknown object: {"done":false,"value":{"value":{"token":{"type":{"klass":{"name":"Identifier","isIdentifierName":true},"name":""},"value":"x","slice":{"text":"x","start":1117,"startLocation":{"line":44,"column":15,"filename":"","position":1117},"end":1118}},"bindings":{"_map":{}},"scopesets":{"all":[{"name":"outsideEdge_1"},{"name":"u_5"},{"name":"i_6"}],"phase":{"0":[{"name":"insideEdge0_2"}]}}},"type":"RawSyntax","loc":null}}

Can we close this?