Closed scabug closed 13 years ago
Imported From: https://issues.scala-lang.org/browse/SI-3175?orig=1 Reporter: Atsuhiko Yamanaka (ymnk) Attachments:
Atsuhiko Yamanaka (ymnk) said: a patch to fix the reported crash bug
@paulp said: (In r21164) Tighten update check in cleanup. Closes #3175. No review.
@paulp said: Thanks for the patch.
Atsuhiko Yamanaka (ymnk) said: IMHO, this is not a bug, but the first argument of "update" and "apply" methods should be checked if it is Int type or not. Without such a check, the dead code(, which never be invoked) will be generated.
def isArrayMethodSignature =
(methSym.name == nme.length && params.isEmpty) ||
(methSym.name == nme.update &&
(structResType.typeSymbol eq UnitClass) &&
params.size == 2) ||
(methSym.name == nme.apply && params.size == 1) ||
(methSym.name == nme.clone_ && params.isEmpty)
@paulp said: Replying to [comment:3 ymnk]:
IMHO, this is not a bug, but the first argument of "update" and "apply" methods should be checked if it is Int type or not.
No, it's a bug, there's no reason it shouldn't utilize all available information. Array only has 4 methods, we ought to be able to nail them! I checked in something closer to optimal in r21224.
@paulp said: (In r21226) During my last look at r21224 I noticed what must be a long standing bug in Array.update handling. Fixing this probably never to be noticed corner case (see bug3175.scala) seduced me into drumming out some duplication. At least we got some nice commenting out of it. Review by dubochet.
If the structural type has the update method with empty or 1 argument, it will crash scalac and REPL on 2.8Beta1 and nightly build.
Originally, this bug was reported at http://old.nabble.com/-scala--a-compiler-crash-on-2.8.Beta1-to27846332.html The attached patch will fix this crash bug.