Commit f9b0e644 authored by Damien George's avatar Damien George
Browse files

py/compile: Provide terse error message for invalid dict/set literals.

parent 18c059fe
...@@ -2433,13 +2433,21 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) { ...@@ -2433,13 +2433,21 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
compile_node(comp, pn_i); compile_node(comp, pn_i);
if (is_dict) { if (is_dict) {
if (!is_key_value) { if (!is_key_value) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dictionary"); if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax");
} else {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict");
}
return; return;
} }
EMIT(store_map); EMIT(store_map);
} else { } else {
if (is_key_value) { if (is_key_value) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set"); if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax");
} else {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set");
}
return; return;
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment