Skip to content

Java: tolerate fields and classes with the name "nil" #4329

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

Merged
merged 1 commit into from
Mar 6, 2019

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Mar 5, 2019

fieldref_exprt confused ID_nil with ID_empty_string and therefore rejected "class nil { int nil; }" for example.

@@ -352,7 +352,8 @@ class fieldref_exprt : public exprt
template <>
inline bool can_cast_expr<fieldref_exprt>(const exprt &base)
{
return base.get(ID_class) != ID_nil && base.get(ID_component_name) != ID_nil;
return base.get(ID_class) != ID_empty_string &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about return !base.get(ID_class).empty() && !base.get(ID_component_name).empty();?

And while I'm at it: would mind adding a test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

fieldref_exprt confused ID_nil with ID_empty_string and therefore rejected "class nil { int nil; }" for example.
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 796f7e1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103234960
Status will be re-evaluated on next push.
Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)

  • the author is not in the list of contributors (e.g. first-time contributors).

  • the compatibility was already broken by an earlier merge.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for adding a test!

@smowton smowton merged commit b9b6dac into diffblue:develop Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants