[ nice-Bugs-1216727 ] Compiler crash with wildcards
"SourceForge.net" <[email protected]> Thu, 09 Jun 2005 16:15:22 -0700
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1216727, was opened at 2005-06-07 23:53
Message generated for change (Comment added) made by bonniot
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1216727&group_id=12788
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Bryn Keller (xoltar)
Assigned to: Daniel Bonniot (bonniot)
Summary: Compiler crash with wildcards
Initial Comment:
C:\>nicec --version
Nice compiler version 0.9.11 (build 2005.06.07,
10:52:36 UTC)
Compiled using JDK 1.4.2
Copyright (C) 2003 Daniel Bonniot
Visit the Nice homepage: http://nice.sourceforge.net
This code:
interface FList<T> {
boolean isEmpty();
}
abstract class ConsList<T> finally implements FList<T> {}
class Cons<T> extends ConsList<T>
{
T head;
ConsList<T> tail;
isEmpty() = false;
}
class Nil<T> extends ConsList<T>
{
isEmpty() = true;
}
/** The singleton. */
private let Nil<?> NIL = new Nil();
/** Returns the Nil singleton. */
ConsList<?> nil() = NIL;
/** Returns a new cons cell. */
<T> ConsList<T> cons(T item, ConsList<T> tail) =
new Cons(head: item, tail: tail);
void _testEmpty()
{
assert nil().isEmpty;
assert !cons(1,nil()).isEmpty;
}
produces this crash:
An exception has occured in the compiler
Please fill-in a bug report at the following webpage:
http://sourceforge.net/tracker/?func=add&group_id=12788&atid=112788
Stack trace:
Exception in thread "main" mlsub.typing.InternalError:
Simplifying ill-formed po
lytype: <T | scratch.ConsList<?> <:
scratch.ConsList<T>, nice.lang.byte <: T> (T
, scratch.ConsList<T>)
at
mlsub.typing.Polytype.simplify(Polytype.java:286)
at bossa.syntax.fun.setComputedType(call.nice:102)
at bossa.syntax.CallExp.setComputedType(call.nice)
at
bossa.syntax.fun.resolveOverloading(overloadedsymbol.nice:161)
at
bossa.syntax.dispatch.resolveOverloading(Unknown Source)
at
bossa.syntax.fun.resolveOverloading(call.nice:54)
at
bossa.syntax.CallExp.resolveOverloading(call.nice)
at bossa.syntax.fun.computeType(call.nice:69)
at bossa.syntax.CallExp.computeType(call.nice)
at
bossa.syntax.Expression.getType(Expression.java:109)
at bossa.syntax.fun.typecheck(typecheck.nice:242)
at bossa.syntax.dispatch.typecheck(Unknown Source)
at
bossa.syntax.fun.typecheckArgs(typecheck.nice:124)
at
bossa.syntax.Arguments.typecheckArgs(arguments.nice)
at bossa.syntax.fun.typecheck(typecheck.nice:221)
at bossa.syntax.dispatch.typecheck(Unknown Source)
at
bossa.syntax.fun.typecheckArgs(typecheck.nice:124)
at
bossa.syntax.Arguments.typecheckArgs(arguments.nice)
at bossa.syntax.fun.typecheck(typecheck.nice:221)
at bossa.syntax.dispatch.typecheck(Unknown Source)
at
bossa.syntax.fun.typecheckArgs(typecheck.nice:124)
at
bossa.syntax.Arguments.typecheckArgs(arguments.nice)
at bossa.syntax.fun.typecheck(typecheck.nice:221)
at bossa.syntax.dispatch.typecheck(Unknown Source)
at bossa.syntax.fun.typecheck(typecheck.nice:891)
at bossa.syntax.dispatch.typecheck(Unknown Source)
at bossa.syntax.fun.lambda77(typecheck.nice:805)
at bossa.syntax.fun.apply1(Unknown Source)
at
gnu.expr.ModuleMethod.apply1(ModuleMethod.java:89)
at nice.lang.fun.foreach(collections.nice:141)
at nice.lang.dispatch.foreach(Unknown Source)
at bossa.syntax.fun.typecheck(typecheck.nice:803)
at bossa.syntax.dispatch.typecheck(Unknown Source)
at
bossa.syntax.fun.innerTypecheck(defaultMethod.nice:100)
at
bossa.syntax.DefaultMethodImplementation.innerTypecheck(defaultMethod
.nice)
at
bossa.syntax.fun.innerTypecheck(defaultMethod.nice:28)
at
bossa.syntax.MethodDeclaration.innerTypecheck(methodDeclaration.nice)
at
bossa.syntax.fun.typecheck(methodDeclaration.nice:161)
at
bossa.syntax.MethodDeclaration.typecheck(methodDeclaration.nice)
at bossa.syntax.Node.doTypecheck(Node.java:299)
at bossa.syntax.Node.doTypecheck(Node.java:304)
at bossa.syntax.Node.doTypecheck(Node.java:304)
at bossa.syntax.fun.typechecking(call.nice:186)
at bossa.syntax.CAST.typechecking(ast.nice)
at
bossa.modules.Package.typecheck(Package.java:369)
at mlsub.compilation.fun.lambda31(Unknown Source)
at mlsub.compilation.fun.apply1(Unknown Source)
at
gnu.expr.ModuleMethod.apply1(ModuleMethod.java:89)
at nice.lang.fun.foreach(collections.nice:141)
at nice.lang.dispatch.foreach(Unknown Source)
at
mlsub.compilation.fun.compileComponent(make.nice:29)
at
mlsub.compilation.dispatch.compileComponent(Unknown Source)
at mlsub.compilation.fun$make.lambda30(Unknown
Source)
at mlsub.compilation.fun$make.apply1(Unknown
Source)
at
gnu.expr.ModuleMethod.apply1(ModuleMethod.java:89)
at nice.lang.fun.foreach(collections.nice:141)
at nice.lang.dispatch.foreach(Unknown Source)
at mlsub.compilation.fun.make(make.nice:44)
at mlsub.compilation.dispatch.make(Unknown Source)
at
nice.tools.compiler.fun.compile(interface.nice:40)
at nice.tools.compiler.dispatch.compile(Unknown
Source)
at
nice.tools.compiler.console.fun.compile(main.nice:165)
at
nice.tools.compiler.console.dispatch.compile(Unknown
Source)
at
nice.tools.compiler.console.fun.main(main.nice:199)
at
nice.tools.compiler.console.dispatch.main(Unknown Source)
----------------------------------------------------------------------
Comment By: Daniel Bonniot (bonniot)
Date: 2005-06-10 01:15
Message:
Logged In: YES
user_id=88952
This bug has been fixed. The next release of the compiler will
include this correction. In the mean time, I encourage you try
the development version. It contains a version of the compiler
that fixes the bug. Please try it and reopen the bug-report if
you find any problem with it.
To know how to get an install the development version of the
compiler that fixes this bug, please read
http://nice.sf.net/cgi-bin/twiki/view/Dev/DevelopmentVersion
Note that the bug has first been fixed in the CVS version, and it
might take one or two hours until the development version
includes the fix.
Thanks again for your help by submiting this bug report.
Daniel Bonniot
----------------------------------------------------------------------
Comment By: Daniel Bonniot (bonniot)
Date: 2005-06-08 12:08
Message:
Logged In: YES
user_id=88952
As a consequence of ? being existential ("some type", not
"any type"), the call cons(1,nil()) is ill-typed. This
should of course be reported nicely, not with a crash!
Simplified testcase:
class Cons<T> {
T head;
Cons<T> tail;
boolean isEmpty() = false;
}
void _testEmpty(Cons<?> c)
{
assert !new Cons(head: 1, tail: c).isEmpty;
}
----------------------------------------------------------------------
Comment By: Daniel Bonniot (bonniot)
Date: 2005-06-08 00:13
Message:
Logged In: YES
user_id=88952
Thanks for the report, I'll investigate that tomorrow. But
note that
ConsList<?> nil()
is probably not what you want, since it has an unknown
(existential) type parameter, so you cannot use it with any
specific expected type parameter. That is, ConsList<String>
l = nil() should then fail. You rather want
<T> ConsList<T> nil()
(If FList is supposed to be immutable, you can also make it
covariant, but that's irrelevant here)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1216727&group_id=12788
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20