Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
go2pins
Commits
ef351ebe
Commit
ef351ebe
authored
Jan 14, 2020
by
Etienne Renault
Browse files
Restricted support for closures encountered in RERS
Thanks to A. Martin for this patch * transform/functiondefs.go: here.
parent
894a07f1
Changes
1
Show whitespace changes
Inline
Side-by-side
transform/functiondefs.go
View file @
ef351ebe
...
...
@@ -29,6 +29,7 @@ func G2PFunction_fibonacci(G2PState G2PStateType) []G2PStateType {
// FunctionDefs visitor type, keeps track of the current function definition.
type
FunctionDefs
struct
{
currentFunction
*
ast
.
Object
inFuncLit
bool
}
// Pre traversal applies the transformation.
...
...
@@ -63,8 +64,12 @@ func (t *FunctionDefs) Pre(meta *Meta, v *Visitor) bool {
},
},
})
case
*
ast
.
FuncLit
:
t
.
inFuncLit
=
true
return
true
case
*
ast
.
ReturnStmt
:
if
len
(
n
.
Results
)
==
0
{
if
len
(
n
.
Results
)
==
0
||
t
.
inFuncLit
{
// Either the function returns nothing or we used named return values.
return
true
}
...
...
@@ -81,6 +86,12 @@ func (t *FunctionDefs) Pre(meta *Meta, v *Visitor) bool {
}
// Post traversal does nothing.
func
(
FunctionDefs
)
Post
(
meta
*
Meta
,
v
*
Visitor
)
bool
{
func
(
t
*
FunctionDefs
)
Post
(
meta
*
Meta
,
v
*
Visitor
)
bool
{
c
:=
v
.
Cursor
()
switch
c
.
Node
()
.
(
type
)
{
case
*
ast
.
FuncLit
:
t
.
inFuncLit
=
false
}
return
true
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment