Skip to content

Fix Bug in Painless Assignment#18379

Merged
jdconrad merged 5 commits intoelastic:masterfrom
jdconrad:types
May 16, 2016
Merged

Fix Bug in Painless Assignment#18379
jdconrad merged 5 commits intoelastic:masterfrom
jdconrad:types

Conversation

@jdconrad
Copy link
Copy Markdown
Contributor

@jdconrad jdconrad commented May 16, 2016

Added some tests for Def optimization and found a minor bug in assignment under a rare corner case.

@rmuir
Copy link
Copy Markdown
Contributor

rmuir commented May 16, 2016

Lets get @uschindler to look. I do like the little bytecode assert in the test for now :)

@uschindler
Copy link
Copy Markdown
Contributor

Looks OK. Sorry for the issue :-)

if (last instanceof ADefLink) {
final ADefLink lastDef = (ADefLink) last;
expression.analyze(settings, definition, variables);
// TODO: does it make more sense to just re-use last.after instead of using storeValueType?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had something similar before, maybe revert back to using ALink.after for that - I was not sure if the operand should always have the same type like the after value. In any case I would keep the superclass ADefLink to make them easier to "detect" in those if statemments, although the ADefLink class is empty afterwards.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@uschindler No worries about the issue. Definitely a somewhat strange corner case :) I agree on keeping it as a marker. It's very clean and clear way to identify these special cases. Do you think it makes more sense to have it as an interface once storeValueType is removed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"marker" interface is also fine. I made it as a class for the special cases we might introduce when we have more "def" types propagation. For now interface is also fine. It would spare to repeat the ctor!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay cool. I'll make it an interface for now, and we can convert it to a class again as needed.

@uschindler
Copy link
Copy Markdown
Contributor

I do like the little bytecode assert in the test for now :)

Yes, very cool. Maybe add some utility method to the ScriptTester base class to do those asserts.

@jdconrad
Copy link
Copy Markdown
Contributor Author

@uschindler Thank you for the feedback. Updated the changes a bit based on your feedback. Everything look okay?

@uschindler
Copy link
Copy Markdown
Contributor

LGTM!

@jdconrad
Copy link
Copy Markdown
Contributor Author

@uschindler Thanks for the review!

@jdconrad jdconrad merged commit ed74e53 into elastic:master May 16, 2016
@jdconrad jdconrad mentioned this pull request May 17, 2016
18 tasks
@jdconrad jdconrad deleted the types branch June 7, 2016 23:17
@clintongormley clintongormley added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache and removed :Plugin Lang Painless labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v5.0.0-alpha3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants