Browse Source

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.
pull/5026/head
Damien George 5 years ago
parent
commit
c7c6703950
  1. 3
      py/compile.c

3
py/compile.c

@ -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;
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
// must be done before compiling the body so that arguments are numbered first (for LOAD_FAST etc)
if (comp->pass == MP_PASS_SCOPE) {

Loading…
Cancel
Save