-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added semantic check for calls to s.bag() from a UDF of s.updateWith* #85
Added semantic check for calls to s.bag() from a UDF of s.updateWith* #85
Conversation
5376edc
to
9d0dbda
Compare
I did some minor modifications on the PR:
|
48866f2
to
b257cd5
Compare
|
||
class InvalidProgramException(message: String = null, cause: Throwable = null) extends Exception(message, cause) {} | ||
|
||
class StatefulAccessedFromUdfException() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions can be defined in the api
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have moved it there.
@@ -241,16 +242,19 @@ private[emma] trait ComprehensionAnalysis | |||
// stateful.updateWithZero(udf) | |||
case q"${updateWithZero @ Select(ident @ Ident(_), _)}[$_]($udf)" | |||
if updateWithZero.symbol == api.updateWithZero => | |||
CheckForStatefulAccessedFromUdf(ident, udf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the semantics checks should be implemented as a separate set of traversers chained together via the ->>
combinator (similarly to the normalization chain).
It will also allow us to keep things clearly separated in the long run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would have the drawback that some of the functionality of comprehend
would be duplicated. I mean, there would be a similar match with the same cases. Do you think this is worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, there will be some duplication, but on the other hand we cleaner code and separation of concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if the checks are added as separate functions and chain together in a similar way as the normalize*
functions (can happen before the normalization phase).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will do it that way then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
6eb633b
to
8768204
Compare
Thanks, I'll merge this in the next batch. |
s <- DataBag(state.get(k(a)).toList) | ||
b <- f(s, a) | ||
} yield b | ||
(k: A => K, f: (S, A) => DataBag[B]): DataBag[B] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer block is redundant.
I've added two minor remarks regarding code formatting and naming. Otherwise I think this can be merged after #88. |
8768204
to
436a5da
Compare
436a5da
to
26e3157
Compare
Thanks, I have addressed all the above comments, and rebased to the current master. I will merge this shortly. |
This is solving the first issue in #84. I implemented what I wrote in the comment there.
(This PR is on top of the commit of #83. I will rebase this, after that is merged.)