swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.58k stars 10.36k forks source link

[SR-1454] Type checker can't resolve operators on floating point types when defined as generic functions #44063

Open gribozavr opened 8 years ago

gribozavr commented 8 years ago
Previous ID SR-1454
Radar None
Original Reporter @gribozavr
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, TypeChecker | |Assignee | None | |Priority | Medium | md5: 83954de486b67c7e457cda85d33f2c19

Issue Description:

Check out https://github.com/apple/swift/pull/2453 and remove the section marked as "TODO: These should not be necessary" in stdlib/public/core/FloatingPointTypes.swift.gyb and all concrete operators in stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb.

The type checker produces strange errors like "error: binary operator '/' cannot be applied to two 'Double' operands".

The diagnostics from removing all operators might be overwhelming, so you can try removing the operators one by one.

stephentyrone commented 8 years ago

The weirdest one I encountered was on binary_operator_perf.swift:


/Volumes/Data/styrone/Checkouts/Swift/swift/test/Interpreter/binary_operator_perf.swift:167:45: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
let size : Double = (q[0]-p[0])*(r[1]-p[1]) - (q[1]-p[1])*(r[0]-p[0])
                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gribozavr commented 8 years ago

To get to that error, you might need to apply the attached patch.

Dante-Broggi commented 6 years ago

Has this been examined? If It has, it's status should be updated.