@@ -13069,7 +13069,38 @@ fn operator_arg_semantic_match( |
| 13069 | 13069 | ), |
| 13070 | 13070 | TypeInfo::ClassStar => matches!(actual, Some(TypeInfo::ClassStar)), |
| 13071 | 13071 | TypeInfo::TypeStar => matches!(actual, Some(TypeInfo::TypeStar)), |
| 13072 | | - _ => true, |
| 13072 | + // Numeric / logical: when the actual type is known, require both |
| 13073 | + // category (Integer/Real/Complex/Logical) and kind to agree. |
| 13074 | + // Unknown actuals (None, e.g. an unresolved expression like |
| 13075 | + // `reshape(...)` that didn't type-check upstream) accept anything |
| 13076 | + // — but the dispatcher then has nothing to discriminate on, so |
| 13077 | + // we can't fall back to wildcard-true here without picking the |
| 13078 | + // first specific in declaration order. F2018 §10.1.5: a defined |
| 13079 | + // operator must have an exact specific match. |
| 13080 | + TypeInfo::Integer { kind: dk } => match actual { |
| 13081 | + Some(TypeInfo::Integer { kind: ak }) => intrinsic_kind_matches(*dk, *ak), |
| 13082 | + None => true, |
| 13083 | + _ => false, |
| 13084 | + }, |
| 13085 | + TypeInfo::Real { kind: dk } => match actual { |
| 13086 | + Some(TypeInfo::Real { kind: ak }) => intrinsic_kind_matches(*dk, *ak), |
| 13087 | + None => true, |
| 13088 | + _ => false, |
| 13089 | + }, |
| 13090 | + TypeInfo::DoublePrecision => matches!( |
| 13091 | + actual, |
| 13092 | + Some(TypeInfo::DoublePrecision) | Some(TypeInfo::Real { kind: Some(8) }) | None |
| 13093 | + ), |
| 13094 | + TypeInfo::Complex { kind: dk } => match actual { |
| 13095 | + Some(TypeInfo::Complex { kind: ak }) => intrinsic_kind_matches(*dk, *ak), |
| 13096 | + None => true, |
| 13097 | + _ => false, |
| 13098 | + }, |
| 13099 | + TypeInfo::Logical { kind: dk } => match actual { |
| 13100 | + Some(TypeInfo::Logical { kind: ak }) => intrinsic_kind_matches(*dk, *ak), |
| 13101 | + None => true, |
| 13102 | + _ => false, |
| 13103 | + }, |
| 13073 | 13104 | } |
| 13074 | 13105 | } |
| 13075 | 13106 | |