[chuck-users] crashing VM on (<string> != null) test?

Hans Aberg haberg at math.su.se
Wed Jun 24 15:30:21 EDT 2009


On 24 Jun 2009, at 21:12, Robert Poor wrote:

> I'm so baffled that this must be easy.  What is the proper test to  
> see if a string is null?  More to the point, why does the following  
> code bomb out on the conditional test?
>
> "foo.txt" => string g;
> <<< g >>>;			// prints '"foo.txt" : (string)'
> if (g != null) {			// evidently crashes here with "[chuck](VM)  
> NullPointerException (during string op)..."
>  <<< "not null" >>>;
> } else {
>  <<< "is null" >>>;
> }

Possibly you have discovered a new type in ChucK :-):

One would expect there to be two types: copy-over data types and  
reference types. And null tests should only be applicable to the  
latter, as the former do not have explicit references. So if strings  
were reference types, you should have an @=> there, and get an error  
on =>. If I change your example to:
null => string g;
<<< g >>>;			// prints '"foo.txt" : (string)'
if (g != null) {			// evidently crashes here with "[chuck](VM)  
NullPointerException (during string op)..."
  <<< "not null" >>>;
} else {
  <<< "is null" >>>;
}

Then 'chuck' hangs for a while, and then (it or the system) reports  
"bus error".

   Hans


  
  


More information about the chuck-users mailing list