mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
fix let without assignment
This commit is contained in:
@@ -1015,7 +1015,12 @@ const eval_statement = (s, scope, calls, context) => {
|
||||
}
|
||||
if(stmt.type == 'let' && s.type == 'identifier') {
|
||||
const node = {...s, result: {ok: true}}
|
||||
return {ok, children: [...children, node], scope, calls}
|
||||
return {
|
||||
ok,
|
||||
children: [...children, node],
|
||||
scope: {...scope, [s.value]: undefined},
|
||||
calls
|
||||
}
|
||||
}
|
||||
const {
|
||||
ok: next_ok,
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -329,6 +329,16 @@ export const tests = [
|
||||
assert_equal(i.value_explorer.result.value, {y: 2, z: 3, q: 4})
|
||||
}),
|
||||
|
||||
test('let variable not initialized bug', () => {
|
||||
const code = `
|
||||
let x
|
||||
x /*label*/
|
||||
`
|
||||
const i = test_initial_state(code, code.indexOf('x /*label'))
|
||||
assert_equal(i.value_explorer.result.ok, true)
|
||||
assert_equal(i.value_explorer.result.value === undefined, true)
|
||||
}),
|
||||
|
||||
test('else if', () => {
|
||||
const code = `
|
||||
let x
|
||||
|
||||
Reference in New Issue
Block a user