Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
62a3a287
Commit
62a3a287
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Set compiler scope before folding constants so error messages work.
Addresses issue #1140.
parent
d0106024
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/compile.c
+7
-6
7 additions, 6 deletions
py/compile.c
with
7 additions
and
6 deletions
py/compile.c
+
7
−
6
View file @
62a3a287
...
...
@@ -3605,15 +3605,16 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is
comp
->
is_repl
=
is_repl
;
comp
->
compile_error
=
MP_OBJ_NULL
;
// optimise constants
// create the module scope
scope_t
*
module_scope
=
scope_new_and_link
(
comp
,
SCOPE_MODULE
,
pn
,
emit_opt
);
// optimise constants (scope must be set for error messages to work)
comp
->
scope_cur
=
module_scope
;
mp_map_t
consts
;
mp_map_init
(
&
consts
,
0
);
pn
=
fold_constants
(
comp
,
pn
,
&
consts
);
module_scope
->
pn
=
fold_constants
(
comp
,
module_scope
->
pn
,
&
consts
);
mp_map_deinit
(
&
consts
);
// set the outer scope
scope_t
*
module_scope
=
scope_new_and_link
(
comp
,
SCOPE_MODULE
,
pn
,
emit_opt
);
// compile pass 1
comp
->
emit
=
emit_pass1_new
();
comp
->
emit_method_table
=
&
emit_pass1_method_table
;
...
...
@@ -3764,7 +3765,7 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is
#endif // !MICROPY_EMIT_CPYTHON
// free the parse tree
mp_parse_node_free
(
pn
);
mp_parse_node_free
(
module_scope
->
pn
);
// free the scopes
mp_raw_code_t
*
outer_raw_code
=
module_scope
->
raw_code
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment