Thursday, January 12, 2012

Ranting Runtime

So to start things off, I decided I would look at a slice of code I had an issue with yesterday. Now first off know that the error in the following code was entirely intentional. I was looking to see how dart, and Dartboard would handle various errors. Looking to see if I would receive a warning, error or runtime error.

First a link to the dartboard (and I'll paste the code in as well until I can figure out how to embed the dartboard into here).

class States {
  static final ON = 1;
  static final OFF = 0;
}

main() {
  var test = new States();
  print('Give try.dartlang.org a try.');
  print('On is: ${States.ON}');
  if(test is States) print('Test is a State instance');
  // The following never prints?
  print('test.ON is: ${test.ON}');
}

Which produces the following output:

Give try.dartlang.org a try.
On is: 1
Test is a State instance

That's it.. no error, no warning. Just did not ever print anything from the final statement. That struck me as really weird. But what I figured was probably happening is that dartboard was receiving a runtime error but didn't display it at all. Still it seemed off to me.

However, after writing a post on Google+, later in the day the dartboard did start reporting the runtime error that was being generated and produced the following:

NoSuchMethodException - receiver: '' function name: 'ON$getter' arguments: []]

Yay! Errors... but errr huh? NoSuchMethodException.. yeah okay I can see that, it's looking for getter method for a class property. But why is the receiver blank? Receiver should be the 'test' instance of the States class. And the arguments are... err what? Okay I can see maybe showing an empty array for the arguments (thus the '[ ]' ) but why am I seeing the extra ']' ? But I well realize that the VM is still in alpha. I've not had a chance yet to go through the issue trackers to see if these are known bugs but being that they are so prominent I have reason to believe they are.

No comments:

Post a Comment