Re: nullness in assignments

Daniel Bonniot <[email protected]> Tue, 01 Mar 2005 11:02:29 +0100
Newsgroups gmane.comp.lang.nice.devel
Message-ID <[email protected]>
Artem Gr wrote:
> I'm trying to implement the RFE# 681385.

Great!

 > Am i going in the right direction?

Yes, the general idea looks good.

A few comments on the way:

> +    if( null != variable ){

Any reason to put null first? Is that you C/C++ backgroud? ;-)
Since tests only work on booleans, there is no risk of mistaking = for ==, 
which is the reason I know for such "reversed" tests. No big deal, but this 
distracts the reader for half a second...


> +      let valueType = e.value.type, toType = to.type, varType = variable.type;
> +      if(  null != valueType && null != toType && null != varType ) try{
> +        checkNotNull( valueType ); // Will throw a TypingEx if the 'value' is not a sureTC.
> +        boolean already = false;
> +        try{ checkNotNull( toType ); already = true; }catch(mlsub.typing.TypingEx good) {}
> +        if( ! already ){
> +          bossa.util.User.warning( e, e.toString() );
> +          mlsub.typing.Monotype type = varType;
> +          mlsub.typing.Monotype sureType = makeSure( type );
> +          setVarType( variable, now: sureType, out: type );
> +        }
> +      }catch(mlsub.typing.TypingEx skip) {}

I think the logic would be clearer if checkNotNull was modified to be a 
isNotNull method, instead of catching exceptions when you use it. The only 
other use of checkNotNull would also benefit from this.

> With this the
> <mac-nicec-new package="bossa.syntax" args="--recompile-all" />
> of the Ant script (target "compiler2") passes successfully,
> which meanst that the compiler was recompiled with intermediate self,
> but the next line, where the new compiler is used, is failing with

So this seems to mean that the modified version generates wrong code.

After you produced a modified compiler, I advise to use it on the testsute 
first, before trying to recompile itself. If that fails, you immediately have 
a small testcase that manifests the problem, so it's easier to track it down.
Once the testsuite passes, you can try bootstraping.

> 
>      [java] nice.lang: parsing
> 
>      [java] An exception has occured in the compiler
>      [java] Please fill-in a bug report at the following webpage:
>      [java] http://sourceforge.net/tracker/?func=add&group_id=12788&atid=112788
> 
>      [java] Stack trace:
>      [java] Exception in thread "main" nice.tools.code.EnsureTypeProc has wrong type

This is a cast failing. More precisely, EnsureTypeProc is used when the 
compiler has a more precise typing information than the jvm verifier can have, 
typically with the return value of a generic methods.

Good luck, don't hesitate to ask for more help.

Daniel


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click