aboutsummaryrefslogtreecommitdiff
path: root/py/compile.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-08-28 11:37:43 +1000
committerDamien George <damien.p.george@gmail.com>2019-08-30 16:43:46 +1000
commitc7c6703950ef14f04ff9ad9d6b61b4b0666144c0 (patch)
tree65b1958a0bcf45c314ac8f549a4f6639ab9bbecc /py/compile.c
parent400a128e11b94cc268685d1b7b26c613a34ca8c3 (diff)
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.
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/compile.c b/py/compile.c
index 829472c0d..41ff66a8c 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) {