Skip to content

Commit f9b0e64

Browse files
committed
py/compile: Provide terse error message for invalid dict/set literals.
1 parent 18c059f commit f9b0e64

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

py/compile.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,13 +2433,21 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
24332433
compile_node(comp, pn_i);
24342434
if (is_dict) {
24352435
if (!is_key_value) {
2436-
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dictionary");
2436+
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
2437+
compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax");
2438+
} else {
2439+
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dict");
2440+
}
24372441
return;
24382442
}
24392443
EMIT(store_map);
24402444
} else {
24412445
if (is_key_value) {
2442-
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set");
2446+
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
2447+
compile_syntax_error(comp, (mp_parse_node_t)pns, "invalid syntax");
2448+
} else {
2449+
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting just a value for set");
2450+
}
24432451
return;
24442452
}
24452453
}

0 commit comments

Comments
 (0)