Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frog handling null incorrectly #595

Closed
dgrove opened this issue Nov 24, 2011 · 10 comments
Closed

frog handling null incorrectly #595

dgrove opened this issue Nov 24, 2011 · 10 comments
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@dgrove
Copy link
Contributor

dgrove commented Nov 24, 2011

svn r1844

There are a variety of cases where frog is handling null incorrectly. A few examples are below:

f() => null;

main() {
print (~f());
}


f() => null;

main() {
print(f());
}


running the VM produces an error in both cases:

NullPointerException
 0. Function: 'Object.noSuchMethod' url: 'bootstrap' line:315 col:3
 1. Function: '::.main' url: '/Users/dgrove/repo/dart-bleeding/dart/frog/y.dart' line:4 col:7

running frog produces "0" in both cases.

Another example:

f() => null;

main() {
print(f() + 7);
}

frog produces "7", the VM throws an exception.

@rakudrama
Copy link
Member

When I run the second one on the VM, it prints 'null', which is the only sane behaviour.

For
    f() => null;
    main() => print(~f());
I see the VM throws NPE, Frog prints '-1'

I am running with --enable_type_checks so I expect correct behaviour. (Without --enable_type_checks you might argue that the NPE is a kind of type check on the receiver, so anything goes.)

This example has no exceptions to the issue:
    foo([x]) => '$x';
    main() => Expect.equals('null', foo());
Expect.equals(expected: <null>, actual: <undefined>) fails.
...
I see 'undefined' in interpolated strings fairly often.

@dgrove
Copy link
Contributor Author

dgrove commented Nov 28, 2011

Added Triaged label.

@dgrove
Copy link
Contributor Author

dgrove commented Nov 28, 2011

Added this to the FrogEditor milestone.

@jmesserly
Copy link

Yeah, I would expect the negative tests to fail with --enable_type_checks. I'm kind of surprised they aren't working already. I think it happens because operators aren't correctly dispatched as "var".

Regarding the toString issue--I'm not sure what to do there. We either need to give up on undefined being a synonym for null, or generate uglier string interp/concat and toString code.

@jmesserly
Copy link

btw, the toString issue should be addressed in this separate bug: http://code.google.com/p/dart/issues/detail?id=618

@jmesserly
Copy link

BTW, I think the fix for:
  http://code.google.com/p/dart/issues/detail?id=596

...will fix this too.

@jmesserly
Copy link

Marked this as being blocked by #596.

@DartBot
Copy link

DartBot commented Jan 16, 2012

This comment was originally written by jimhug@google.com


Also for the record, I tried these tests in dartc. Dartc does correctly handle the "f() + 7" case; however, it is equally broken as frog on the "7 + f()" case - although dartc seems to return NaN instead of 7. Nevertheless, we will fix this as part of the editor milestone.


cc @kasperl.

@DartBot
Copy link

DartBot commented Jan 17, 2012

This comment was originally written by jimhug@google.com


Set owner to jimhug@google.com.
Added Started label.

@DartBot
Copy link

DartBot commented Jan 23, 2012

This comment was originally written by jimhug@google.com


r3505 fixes the specific issues reported in this bug and generally improves null handling in frog.


Added Fixed label.

@dgrove dgrove added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures labels Jan 23, 2012
@dgrove dgrove added this to the FrogEditor milestone Jan 23, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

4 participants