fortrangoingonforty/armfortas / 5f0735f

Browse files

Keep intrinsic repeat reachable when first arg is character

Authored by espadonne
Committed by mfwolffe
SHA
5f0735fa7249d3f17a2ad5ea107d229a1d16c4ff
Parents
c7a292f
Tree
c33e39b

1 changed file

StatusFile+-
M src/ir/lower/core.rs 18 1
src/ir/lower/core.rsmodified
@@ -15479,8 +15479,25 @@ pub(super) fn lower_string_expr_full(
15479
                 // NamedInterface shadows the name, skip the intrinsic
15479
                 // NamedInterface shadows the name, skip the intrinsic
15480
                 // match arms and fall through to the user-defined
15480
                 // match arms and fall through to the user-defined
15481
                 // function resolution path.
15481
                 // function resolution path.
15482
+                //
15483
+                // F2008 §12.5.5.2 generic resolution: the user-defined
15484
+                // generic only shadows the intrinsic for argument
15485
+                // signatures that match one of its specifics. stdlib's
15486
+                // `repeat` generic only has `(string_type, integer)`,
15487
+                // so `repeat(' ', 5)` (character first arg) must still
15488
+                // dispatch to the intrinsic. Without this refinement
15489
+                // the gate fired unconditionally, the intrinsic match
15490
+                // arm was skipped, the user-resolution path called the
15491
+                // intrinsic runtime correctly but failed to compute
15492
+                // the result length — silently emitting len=0 to
15493
+                // afs_assign_char_deferred and producing empty strings
15494
+                // (blocks process_1/process_6 and any deferred-length
15495
+                // = repeat(char, n) downstream of `use stdlib_strings`).
15482
                 let user_named_interface_shadows_intrinsic =
15496
                 let user_named_interface_shadows_intrinsic =
15483
-                    find_named_interface_symbol(st, &key).is_some();
15497
+                    find_named_interface_symbol(st, &key).is_some()
15498
+                        && !first_char_arg
15499
+                            .map(|arg| expr_is_character_expr(b, locals, arg, st, type_layouts))
15500
+                            .unwrap_or(false);
15484
                 let intrinsic_key = if user_named_interface_shadows_intrinsic {
15501
                 let intrinsic_key = if user_named_interface_shadows_intrinsic {
15485
                     ""
15502
                     ""
15486
                 } else {
15503
                 } else {