Skip to content
Snippets Groups Projects
Commit ae6fe8b4 authored by Milan Rossa's avatar Milan Rossa Committed by Damien George
Browse files

py/compile: Improve the line numbering precision for comprehensions.

The line number for comprehensions is now always reported as the correct
global location in the script, instead of just "line 1".
parent 7d851a27
No related branches found
No related tags found
No related merge requests found
...@@ -3112,6 +3112,9 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { ...@@ -3112,6 +3112,9 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
scope->num_pos_args = 1; scope->num_pos_args = 1;
} }
// Set the source line number for the start of the comprehension
EMIT_ARG(set_source_line, pns->source_line);
if (scope->kind == SCOPE_LIST_COMP) { if (scope->kind == SCOPE_LIST_COMP) {
EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST); EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST);
} else if (scope->kind == SCOPE_DICT_COMP) { } else if (scope->kind == SCOPE_DICT_COMP) {
......
...@@ -449,6 +449,7 @@ arg names: * * * ...@@ -449,6 +449,7 @@ arg names: * * *
(N_STATE 9) (N_STATE 9)
(N_EXC_STACK 0) (N_EXC_STACK 0)
bc=-\\d\+ line=1 bc=-\\d\+ line=1
bc=0 line=59
00 LOAD_NULL 00 LOAD_NULL
01 LOAD_FAST 2 01 LOAD_FAST 2
02 LOAD_NULL 02 LOAD_NULL
...@@ -471,6 +472,7 @@ arg names: * * * ...@@ -471,6 +472,7 @@ arg names: * * *
(N_STATE 10) (N_STATE 10)
(N_EXC_STACK 0) (N_EXC_STACK 0)
bc=-\\d\+ line=1 bc=-\\d\+ line=1
bc=0 line=60
00 BUILD_LIST 0 00 BUILD_LIST 0
02 LOAD_FAST 2 02 LOAD_FAST 2
03 GET_ITER_STACK 03 GET_ITER_STACK
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment