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

JsonQueryFunction always defaults to rootScope and fails when alternative Scope is required. #17

Closed
nickbreentvnz opened this issue Oct 18, 2017 · 2 comments

Comments

@nickbreentvnz
Copy link
Contributor

When loading all macros, they are all created without specifying a Scope.

addFunction(def.name, def.args.size(), new JsonQueryFunction(def.name, def.args, JsonQuery.compile(def.body)));

Which is a call to:

public JsonQueryFunction(final String name, final List<String> params, final JsonQuery body) {
this(name, params, body, Scope.rootScope());
}

... which uses Scope.rootScope() which is not guaranteed to be the same scope as the query has been compiled with.

My hunch is that Scope.loadMacros just needs to call new JsonQueryFunction with this as the closure scope, though I've yet to prove it or encode it in a unit test.

addFunction(def.name, def.args.size(), new JsonQueryFunction(def.name, def.args, JsonQuery.compile(def.body), this));
eiiches added a commit that referenced this issue Jul 17, 2018
@eiiches
Copy link
Owner

eiiches commented Jul 17, 2018

Thanks. I think you are right.

Fixed in 41bda39.

@eiiches
Copy link
Owner

eiiches commented Jul 27, 2018

@eiiches eiiches closed this as completed Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants