Skip to content

Bug with local variables creation  #165

Open
@DaniilStepanov

Description

@DaniilStepanov

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"
    }

}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingir

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions