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

Cannot borrow var float64 in infix assignment #14440

Closed
mratsim opened this issue May 24, 2020 · 2 comments · Fixed by #14771
Closed

Cannot borrow var float64 in infix assignment #14440

mratsim opened this issue May 24, 2020 · 2 comments · Fixed by #14771

Comments

@mratsim
Copy link
Collaborator

mratsim commented May 24, 2020

The following does not work and returns a strange error:

type Radians = distinct float64

func `-=`(a: var Radians, b: Radians) {.borrow.}

var a = Radians(1.0)
let b = Radians(1.0)

a -= b

echo a.float64
Error: type mismatch: got <var float64, float64>
but expected one of: 
func `-=`(a: var Radians; b: Radians)
  first type mismatch at position: 1
  required type for a: var Radians
  but expression '' is of type: var float64

expression: `-=`()

So it seems like the distinct type was correctly unwrapped but then the actual expression was not properly forwarded to the rest of the semcheck pass?

@mratsim
Copy link
Collaborator Author

mratsim commented May 24, 2020

And another one, it's probably the infix:

type Time = distinct float32

func `<`(a, b: Time): bool {.borrow.}

echo Time(1) < Time(2)
Error: type mismatch: got <float32, float32>
but expected one of: 
func `<`(a, b: Time): bool
  first type mismatch at position: 1
  required type for a: Time
  but expression '' is of type: float32

expression: `<`()

@planetis-m
Copy link
Contributor

Fixed with ebd1cc0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants