From c7c6703950ef14f04ff9ad9d6b61b4b0666144c0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 28 Aug 2019 11:37:43 +1000 Subject: [PATCH] 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. --- py/compile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/compile.c b/py/compile.c index 829472c0d7..41ff66a8ca 100644 --- a/py/compile.c +++ b/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) {