-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsFeature: expressionsfor-in loopsFeature: for-in loopsFeature: for-in loopsgenericsFeature: generic declarations and typesFeature: generic declarations and typesinternal errorBug: Internal errorBug: Internal erroroperatorsFeature: operatorsFeature: operatorsstatementsFeature: statementsFeature: statementsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
% swift coord.swift
coord.swift:8:9: error: failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
for b in Int(minB) ..< ValueType.max {
^
when the left-hand side of the range operator was changed from 0 to Int(minB)
.
Reproduction
struct Coord {
private typealias ValueType = Int16
init<T>(clamping value: T) where T : BinaryInteger {
let minB = (Double(value - T(ValueType.max)) / 3.0).rounded(.down)
for b in Int(minB) ..< ValueType.max {
}
fatalError("TODO")
}
}
Stack dump
none
Expected behavior
The rhs to the range operator is of type Int16. If that is changed to Int(ValueType.max)
, to match the type of the lhs, problem goes away.
Is "failed to produce diagnostic" the best diagnostic the compiler can produce to explain what is wrong with the source code?
Environment
% swift -version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsFeature: expressionsfor-in loopsFeature: for-in loopsFeature: for-in loopsgenericsFeature: generic declarations and typesFeature: generic declarations and typesinternal errorBug: Internal errorBug: Internal erroroperatorsFeature: operatorsFeature: operatorsstatementsFeature: statementsFeature: statementsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis