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

Weird bug with augmented assignment and Int constant value #103

Open
tobia opened this issue Mar 7, 2020 · 2 comments
Open

Weird bug with augmented assignment and Int constant value #103

tobia opened this issue Mar 7, 2020 · 2 comments

Comments

@tobia
Copy link

tobia commented Mar 7, 2020

I spent hours tracking down this bug, because the code compiled and looked fine to me:

val m1 = mat[0.5]
m1[0] -= 1
println(m1[0]) // 0.0 WRONG!

When I replaced the 1 with 1.0 (out of lack of things to try) the bug went away:

val m2 = mat[0.5]
m2[0] -= 1.0
println(m2[0]) // -0.5 correct

What's weird is that Kotlin has no issue with auto-casting a constant to double:

val m3 = mat[0.5]
println(m3[0] - 1) // -0.5 correct

So the bug only appears when using augmented assignments (+=, -=, etc.)

I have no idea how to debug this.

I'm using Koma EJML 0.12, Kotlin 1.3.61, Java 1.8.0_242

@kyonifer
Copy link
Owner

Thanks for the report.

This project is only lightly maintained at the moment, but we'll try to take a look when possible.

@tobia
Copy link
Author

tobia commented Mar 12, 2020

Sure. I just wanted to open an issue in case others run into it. In fact, augmented assignments are converted to regular assignments by the Kotlin compiler, so I don't exclude the possibility that this is a Kotlin compiler bug.

In any case, it may be lightly maintained as of now, but it's still the best math library for Kotlin bar none.

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

No branches or pull requests

2 participants