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

Bug with local variables creation #165

Open
DaniilStepanov opened this issue Sep 5, 2023 · 3 comments
Open

Bug with local variables creation #165

DaniilStepanov opened this issue Sep 5, 2023 · 3 comments
Assignees
Labels
bug Something isn't working ir

Comments

@DaniilStepanov
Copy link
Collaborator

DaniilStepanov commented Sep 5, 2023

Because of this condition instructions like 0=1 are possible. It is wrong behavior. Possible fix:
add additional condition:
if ((oldVar.typeName == expr.typeName && oldVar !is JcRawConstant) || (expr is JcRawNullConstant && !oldVar.typeName.isPrimitive)) {

Failing test:

class InvokeMethodWithException {

    class A {
        fun lol(a: Int): Int {
            return 888/a
        }
    }

    fun box():String {
        val method = A::class.java.getMethod("lol", Int::class.java)
        var failed = false
        try {
            method.invoke(null, 0)
        }
        catch(e: Exception) {
            failed = true
        }

        return if (!failed) "fail" else "OK"
    }

}
@lehvolk lehvolk self-assigned this Sep 5, 2023
lehvolk added a commit that referenced this issue Sep 5, 2023
@lehvolk
Copy link
Collaborator

lehvolk commented Sep 5, 2023

@DaniilStepanov Could you please check this test . This test is green at the moment

lehvolk added a commit that referenced this issue Sep 5, 2023
* Wrong conversion of some condition instructions with zero comparison from IR to jvm bytecode #167
Wrong conversion of numeric constants from IR to jvm bytecode #166

* Bug with local variables creation #165
@DaniilStepanov
Copy link
Collaborator Author

yes, it fixed

@DaniilStepanov
Copy link
Collaborator Author

Try this test:

fun box(): String {
    var x = ""
    run { x = "OK" }
    return x
}

@lehvolk lehvolk added the bug Something isn't working label Sep 15, 2023
@lehvolk lehvolk added the ir label Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ir
Projects
None yet
Development

No branches or pull requests

2 participants