#788 Coercion of indexed assignment shortcut

KevinKelley Fri 16 Oct 2009

This test case:

class bug
{
  Int[] indexes := Int[,]

  Int? entryForIndex(Int index) { return 1 }

  Void modify(Int start)
  {
    ip := entryForIndex(start) ?: 0
    indexes[ip] += 1
  }

  Void main() {}
}

generates this error trace:

java.lang.VerifyError: (class: fan/bug_0/bug, method: modify signature: (J)V) Expecting to find object/array on stack
  at java.lang.Class.getDeclaredFields0(Native Method)
  at java.lang.Class.privateGetDeclaredFields(Unknown Source)
  at java.lang.Class.getDeclaredFields(Unknown Source)
  at fan.sys.ClassType.finishSlots(ClassType.java:591)
  at fan.sys.ClassType.finish(ClassType.java:554)
  at fan.sys.Method$MethodFunc.isStatic(Method.java:459)
  at fan.sys.Method$MethodFunc.callList(Method.java:175)
  at fan.sys.Type.make(Type.java:242)
  at fan.sys.ClassType.make(ClassType.java:112)
  at fan.sys.Type.make(Type.java:232)
  at fanx.tools.Fan.callMain(Fan.java:138)
  at fanx.tools.Fan.executeFile(Fan.java:89)
  at fanx.tools.Fan.execute(Fan.java:35)
  at fanx.tools.Fan.run(Fan.java:241)
  at fanx.tools.Fan.main(Fan.java:279)
sys::Err: Method not mapped to java.lang.reflect correctly bug_0::bug.make
  fan.sys.Method$MethodFunc.isStatic (Method.java:466)
  fan.sys.Method$MethodFunc.callList (Method.java:175)
  fan.sys.Type.make (Type.java:242)
  fan.sys.ClassType.make (ClassType.java:112)
  fan.sys.Type.make (Type.java:232)
  fanx.tools.Fan.callMain (Fan.java:138)
  fanx.tools.Fan.executeFile (Fan.java:89)
  fanx.tools.Fan.execute (Fan.java:35)
  fanx.tools.Fan.run (Fan.java:241)
  fanx.tools.Fan.main (Fan.java:279)

Changing the line

indexes[ip] += 1

to something else makes it go away, but I can't explain this one. Maybe a problem saving a nullable inferred type into a non-nullable array? Or confusion between array.get and the int.plus?

brian Fri 16 Oct 2009

Promoted to ticket #788 and assigned to brian

brian Sun 18 Oct 2009

Renamed from Odd little compiler error to Coercion of indexed assignment shortcut

brian Sun 18 Oct 2009

Ticket resolved in 1.0.47

Move the scratch variable generation from ResolveExpr step to the CheckErrors step after coercion of arguments has been performed.

changeset

Login or Signup to reply.