py/compile: Improve the line numbering precision for lambdas.
Prior to this patch the line number for a lambda would be "line 1" if the body of the lambda contained only a simple expression (with no line number stored in the parse node). Now the line number is always reported correctly.
This commit is contained in:
parent
400a128e11
commit
c7c6703950
|
@ -3078,6 +3078,9 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
|
||||||
mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
|
mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
|
||||||
assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3);
|
assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3);
|
||||||
|
|
||||||
|
// Set the source line number for the start of the lambda
|
||||||
|
EMIT_ARG(set_source_line, pns->source_line);
|
||||||
|
|
||||||
// work out number of parameters, keywords and default parameters, and add them to the id_info array
|
// work out number of parameters, keywords and default parameters, and add them to the id_info array
|
||||||
// must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc)
|
// must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc)
|
||||||
if (comp->pass == MP_PASS_SCOPE) {
|
if (comp->pass == MP_PASS_SCOPE) {
|
||||||
|
|
Loading…
Reference in New Issue