Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9572] Type checker fails to find correct solution #52019

Closed
stephentyrone opened this issue Dec 24, 2018 · 4 comments
Closed

[SR-9572] Type checker fails to find correct solution #52019

stephentyrone opened this issue Dec 24, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@stephentyrone
Copy link
Member

Previous ID SR-9572
Radar None
Original Reporter @stephentyrone
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @stephentyrone
Priority Medium

md5: e62ffdf0d87f5782d9af375ac5aaeceb

Issue Description:

let x: Int = 1
let y = UInt(1) << x - 1 // OK
let z = UInt(1) << (x + 1) - 1 // Error

This should typecheck; the two expressions involve exactly the same types. The error changed between 4.2 and 5.0, but we get an error on both:

4.2: repl.swift:3:28: error: '-' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.
5.0: error: binary operator '-' cannot be applied to operands of type 'UInt' and 'Int'

@stephentyrone
Copy link
Member Author

The correct parse should be:

(UInt(1) << (x + (1 as Int))) - (1 as UInt)

@belkadan
Copy link
Contributor

belkadan commented Jan 7, 2019

cc @xedin

@xedin
Copy link
Member

xedin commented Jan 8, 2019

This is all thanks to `LinkedExprAnalyzer` hack we have to improve performance. It treats both `1` literals as having the same type. We are working on removing most of the performance hacks from the solver...

@hborla
Copy link
Member

hborla commented Jul 23, 2020

This is fixed on master in #33060

Turns out the performance hack for literals doesn't have an impact anymore!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants