mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
fix: only record declared args
This commit is contained in:
@@ -75,7 +75,10 @@ const codegen_function_expr = (node, cxt) => {
|
|||||||
: '(' + do_codegen(node.body) + ')'
|
: '(' + do_codegen(node.body) + ')'
|
||||||
)
|
)
|
||||||
|
|
||||||
const argscount = node.function_args.children.find(a => a.type == 'rest') != null
|
const argscount = node
|
||||||
|
.function_args
|
||||||
|
.children
|
||||||
|
.find(a => a.type == 'destructuring_rest') == null
|
||||||
? node.function_args.children.length
|
? node.function_args.children.length
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
|||||||
22
test/test.js
22
test/test.js
@@ -1838,9 +1838,9 @@ const y = x()`
|
|||||||
const z = () => z2()
|
const z = () => z2()
|
||||||
const y2 = () => 1
|
const y2 = () => 1
|
||||||
const z2 = () => 2
|
const z2 = () => 2
|
||||||
const target = () => target2()
|
const target = (x) => target2(x)
|
||||||
const target2 = () => target3()
|
const target2 = (x) => target3(x)
|
||||||
const target3 = () => 3
|
const target3 = (x) => 3
|
||||||
const deep_call = x => {
|
const deep_call = x => {
|
||||||
if(x == 10) {
|
if(x == 10) {
|
||||||
target(x)
|
target(x)
|
||||||
@@ -1853,12 +1853,12 @@ const y = x()`
|
|||||||
deep_call(0)
|
deep_call(0)
|
||||||
`
|
`
|
||||||
const s1 = test_initial_state(code)
|
const s1 = test_initial_state(code)
|
||||||
const {state: s2} = COMMANDS.move_cursor(s1, code.indexOf('target2()'))
|
const {state: s2} = COMMANDS.move_cursor(s1, code.indexOf('target2(x)'))
|
||||||
|
|
||||||
assert_equal(s2.current_calltree_node.id, s2.active_calltree_node.id)
|
assert_equal(s2.current_calltree_node.id, s2.active_calltree_node.id)
|
||||||
|
|
||||||
assert_equal(s2.current_calltree_node.args, [10])
|
assert_equal(s2.current_calltree_node.args, [10])
|
||||||
assert_equal(s2.current_calltree_node.code.index, code.indexOf('() => target2'))
|
assert_equal(s2.current_calltree_node.code.index, code.indexOf('(x) => target2'))
|
||||||
|
|
||||||
const root = root_calltree_node(s2)
|
const root = root_calltree_node(s2)
|
||||||
const first = root.children[0]
|
const first = root.children[0]
|
||||||
@@ -2416,8 +2416,8 @@ const y = x()`
|
|||||||
|
|
||||||
test('deferred calls', () => {
|
test('deferred calls', () => {
|
||||||
const code = `
|
const code = `
|
||||||
export const fn = () => {
|
export const fn = (x) => {
|
||||||
fn2()
|
fn2(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn2 = () => {
|
const fn2 = () => {
|
||||||
@@ -2435,7 +2435,7 @@ const y = x()`
|
|||||||
|
|
||||||
const call = get_deferred_calls(state)[0]
|
const call = get_deferred_calls(state)[0]
|
||||||
assert_equal(call.fn.name, 'fn')
|
assert_equal(call.fn.name, 'fn')
|
||||||
assert_equal(call.code.index, code.indexOf('() => {'))
|
assert_equal(call.code.index, code.indexOf('(x) => {'))
|
||||||
assert_equal(call.args, [10])
|
assert_equal(call.args, [10])
|
||||||
|
|
||||||
// Expand call
|
// Expand call
|
||||||
@@ -2452,12 +2452,12 @@ const y = x()`
|
|||||||
|
|
||||||
test('deferred calls calltree nav', () => {
|
test('deferred calls calltree nav', () => {
|
||||||
const code = `
|
const code = `
|
||||||
const normal_call = () => {
|
const normal_call = (x) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
normal_call(0)
|
normal_call(0)
|
||||||
|
|
||||||
export const deferred_call = () => {
|
export const deferred_call = (x) => {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -2563,7 +2563,7 @@ const y = x()`
|
|||||||
|
|
||||||
test('deferred_calls find_call then deferred_call bug', () => {
|
test('deferred_calls find_call then deferred_call bug', () => {
|
||||||
const code = `
|
const code = `
|
||||||
export const fn = () => { /* label */ }
|
export const fn = (x) => { /* label */ }
|
||||||
`
|
`
|
||||||
|
|
||||||
const {state: i, on_deferred_call} = test_deferred_calls_state(code)
|
const {state: i, on_deferred_call} = test_deferred_calls_state(code)
|
||||||
|
|||||||
Reference in New Issue
Block a user