diff --git a/civet.dev/.vitepress/components/PlaygroundFull.vue b/civet.dev/.vitepress/components/PlaygroundFull.vue index a2754cbf..2b528d5d 100644 --- a/civet.dev/.vitepress/components/PlaygroundFull.vue +++ b/civet.dev/.vitepress/components/PlaygroundFull.vue @@ -79,6 +79,9 @@ function runInBrowser() { } } catch (err) { console.error(err); + if (err instanceof SyntaxError) { + console.log('Attempted to eval:', code) + } evalOutput.value += `[THROWN] ${err.toString()}\n` } evalComplete.value = true diff --git a/source/parser/lib.civet b/source/parser/lib.civet index 45f7d056..02d32627 100644 --- a/source/parser/lib.civet +++ b/source/parser/lib.civet @@ -1408,6 +1408,7 @@ function processRepl(root: BlockStatement, rootIIFE: ASTNode): void i .= 0 // Hoist top-level declarations and all var declarations for each decl of gatherRecursiveWithinFunction topBlock, .type is "Declaration" + continue unless decl.names?# // skip 'let ref' if decl.parent is topBlock or decl.decl is "var" decl.children.shift() // remove const/let/var root.expressions.splice i++, 0, ["", `var ${decl.names.join ','};`] diff --git a/test/iife.civet b/test/iife.civet index d17096dd..385749ac 100644 --- a/test/iife.civet +++ b/test/iife.civet @@ -151,7 +151,7 @@ describe "repl directive", -> """ testCase """ - inner classesj + inner classes --- "civet repl" if true @@ -176,3 +176,12 @@ describe "repl directive", -> return new C }})() """ + + testCase """ + skip let ref + --- + "civet repl" + primes := [...smallPrimes] ||> .# = n + --- + var primes;(()=>{let ref;primes =( (ref = [...smallPrimes]).length = n,ref);return primes})() + """