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

Java: switching over nullable values may trigger NPE #568

Open
GreyCat opened this issue Apr 18, 2019 · 0 comments
Open

Java: switching over nullable values may trigger NPE #568

GreyCat opened this issue Apr 18, 2019 · 0 comments

Comments

@GreyCat
Copy link
Member

GreyCat commented Apr 18, 2019

Follow up for #300 — original issue mentioned case of enum being null and then being switched over. The problem is actually much deeper and, currently, it's pretty hard to solve without major reworking of expression type derivation to include nullability tracking.

Java allows switching over String or boxed integers (like Integer, Long), which can be null due to:

  • if failing
  • type switching match failed without default case
  • something else?

A very simple repro:

seq:
  - id: always_null
    type: u1
    if: false
  - id: trigger_npe
    type:
      switch-on: always_null
      cases:
        1: one
        _: two

This issue will acts as a reminder, may be we'll return to it one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant