@@ -3194,44 +3194,41 @@ compiler_while(struct compiler *c, stmt_ty s)
3194
3194
static int
3195
3195
compiler_return (struct compiler * c , stmt_ty s )
3196
3196
{
3197
- location loc = LOC (s );
3198
3197
int preserve_tos = ((s -> v .Return .value != NULL ) &&
3199
3198
(s -> v .Return .value -> kind != Constant_kind ));
3200
- if (c -> u -> u_ste -> ste_type != FunctionBlock )
3201
- return compiler_error (c , loc , "'return' outside function" );
3199
+ if (c -> u -> u_ste -> ste_type != FunctionBlock ) {
3200
+ return compiler_error (c , LOC (s ), "'return' outside function" );
3201
+ }
3202
3202
if (s -> v .Return .value != NULL &&
3203
3203
c -> u -> u_ste -> ste_coroutine && c -> u -> u_ste -> ste_generator )
3204
3204
{
3205
- return compiler_error (
3206
- c , loc , "'return' with value in async generator" );
3205
+ return compiler_error (
3206
+ c , LOC ( s ) , "'return' with value in async generator" );
3207
3207
}
3208
3208
3209
3209
if (preserve_tos ) {
3210
3210
VISIT (c , expr , s -> v .Return .value );
3211
3211
} else {
3212
3212
/* Emit instruction with line number for return value */
3213
3213
if (s -> v .Return .value != NULL ) {
3214
- SET_LOC (c , s -> v .Return .value );
3215
- loc = LOC (s -> v .Return .value );
3216
- ADDOP (c , loc , NOP );
3214
+ ADDOP (c , LOC (s -> v .Return .value ), NOP );
3217
3215
}
3218
3216
}
3219
3217
if (s -> v .Return .value == NULL || s -> v .Return .value -> lineno != s -> lineno ) {
3220
- SET_LOC (c , s );
3221
- loc = LOC (s );
3222
- ADDOP (c , loc , NOP );
3218
+ ADDOP (c , LOC (s ), NOP );
3223
3219
}
3224
3220
3225
- if (!compiler_unwind_fblock_stack (c , & loc , preserve_tos , NULL ))
3221
+ location loc = LOC (s );
3222
+ if (!compiler_unwind_fblock_stack (c , & loc , preserve_tos , NULL )) {
3226
3223
return 0 ;
3224
+ }
3227
3225
if (s -> v .Return .value == NULL ) {
3228
- ADDOP_LOAD_CONST (c , loc , Py_None );
3226
+ ADDOP_LOAD_CONST (c , LOC ( s ) , Py_None );
3229
3227
}
3230
3228
else if (!preserve_tos ) {
3231
- ADDOP_LOAD_CONST (c , loc , s -> v .Return .value -> v .Constant .value );
3229
+ ADDOP_LOAD_CONST (c , LOC ( s ) , s -> v .Return .value -> v .Constant .value );
3232
3230
}
3233
- ADDOP (c , loc , RETURN_VALUE );
3234
-
3231
+ ADDOP (c , LOC (s ), RETURN_VALUE );
3235
3232
return 1 ;
3236
3233
}
3237
3234
0 commit comments