-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
It looks like #85797 has broken Float parsing of Substrings. Specifically, the Float parsing now appears to consider the whole base string, not just the relevant piece of the Substring.
Reproduction
func main() {
print(String(describing: Float("0.3")))
print(String(describing: Float("00.3".dropFirst())))
print(String(describing: Float("=0.3".dropFirst())))
print(String(describing: Float("0.35".dropLast())))
}
main()Build and run from the file, e.g. swift test.swift.
This produces:
Optional(0.3)
Optional(0.3)
nil
Optional(0.35)
Observe that the third case fails to parse, even though the = was dropped from the Substring, and the latter case incorrectly parses as 0.35 even though the 5 was dropped as well.
Expected behavior
This should print:
Optional(0.3)
Optional(0.3)
Optional(0.3)
Optional(0.3)
Environment
Swift version 6.3-dev (LLVM cff341857efbfc7, Swift 956dc0c1a258891)
Target: aarch64-unknown-linux-gnu
Build config: +assertions
From latest nightly docker image as of today.
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels