Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Updates to build with the latest SDK #179

Merged
merged 9 commits into from
Feb 20, 2019
Merged

Conversation

juanjux
Copy link
Contributor

@juanjux juanjux commented Feb 14, 2019

This fix some of the fields detected by the new check and explicitly ignores others, with comments and link to #178 in those cases.

@juanjux juanjux added the bug label Feb 14, 2019
@juanjux juanjux self-assigned this Feb 14, 2019
Copy link
Member

@dennwc dennwc left a comment

Choose a reason for hiding this comment

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

Looks good, only few small comments:

driver/normalizer/normalizer.go Outdated Show resolved Hide resolved
"Type": UASTType(uast.FunctionType{}, Fields{
{Name: "Arguments", Op: Var("arguments")},
{Name: "Returns", Optional: "ret_opt", Op: Cases("ret_case",
Is(nil),
Copy link
Member

Choose a reason for hiding this comment

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

Python functions always have an implicit return, so should be a single empty Argument with Init = None when there are no type annotations. There is a similar piece of code in JS).

Copy link
Contributor Author

@juanjux juanjux Feb 15, 2019

Choose a reason for hiding this comment

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

I implemented this and it worked beautifully... but then I noticed that this annotations only has a value IF the function has a Python 3.4+ type annotation BUT if it doesn't have it, it doesn't mean that the function returns None! Just that it's not annotated. So I think is better to left it with the current state (nil if there is no annotation, the annotation if there is one) because otherwise the UAST user could be confused into thinking that some functions return None while in fact they return other types.

Edit: will add a comment to clarify this.

Copy link
Member

Choose a reason for hiding this comment

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

I haven't meant that the function returns None as type, only that if there is no return, all Python2 and Python3 functions returns None implicitly. So it's Returns.Argument.Init: None, same way as we do it in JS with undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but to know if the function returns None implicitly we should parse the function and find the return statement in this case.

driver/normalizer/normalizer.go Outdated Show resolved Hide resolved
driver/normalizer/normalizer.go Outdated Show resolved Hide resolved
Juanjo Alvarez and others added 8 commits February 15, 2019 09:41
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>

Remove some commented code, add some comments
Co-Authored-By: juanjux <juanjo@juanjoalvarez.net>
Co-Authored-By: juanjux <juanjo@juanjoalvarez.net>
- Fixes from review.
- Add comments to the FunctionGroup.
- Add comments to boxes attributes.

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
… that the function returns None

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
@juanjux
Copy link
Contributor Author

juanjux commented Feb 15, 2019

Ready for another review round!

Copy link
Contributor

@bzz bzz left a comment

Choose a reason for hiding this comment

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

LGTM

but the arguments/ask for adding more information to commits with such changes in drivers (example of code + link to language speck + XPath to highlight the change) from elsewhere still holds.

driver/normalizer/normalizer.go Outdated Show resolved Hide resolved
Co-Authored-By: juanjux <juanjo@juanjoalvarez.net>
@juanjux juanjux merged commit 31202a6 into bblfsh:master Feb 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants