mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
not iterable error
This commit is contained in:
@@ -145,20 +145,30 @@ export const find_node = (node, pred) => {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO refactor, have explicit information if node is error origin, without
|
||||
// guessing. See also color.js
|
||||
// TODO check if return result is null and throw early
|
||||
export const find_error_origin_node = node =>
|
||||
find_node(
|
||||
// TODO do not go inside function_expr
|
||||
node,
|
||||
n => n.result != null && !n.result.ok && (
|
||||
n.result.error != null
|
||||
||
|
||||
// In case if throw null or throw undefined
|
||||
n.type == 'throw'
|
||||
||
|
||||
// await can also throw null
|
||||
n.type == 'unary' && n.operator == 'await'
|
||||
// or function call throwing null or undefined
|
||||
||
|
||||
n.type == 'function_call'
|
||||
// node has no error, but its children also have no error, so this node
|
||||
// is error origin
|
||||
n.children.find(c => find_error_origin_node(c) != null) == null
|
||||
&&
|
||||
(
|
||||
// In case if throw null or throw undefined
|
||||
n.type == 'throw'
|
||||
||
|
||||
// await can also throw null
|
||||
n.type == 'unary' && n.operator == 'await'
|
||||
// or function call throwing null or undefined
|
||||
||
|
||||
n.type == 'function_call'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user