Skip to content

Commit 91ed5cb

Browse files
authored
Merge pull request #306 from prettier-solidity/assembly-func-definition
Improve assembly functions without return values
2 parents 693b1fb + 17f1379 commit 91ed5cb

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

src/nodes/AssemblyFunctionDefinition.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ const AssemblyFunctionDefinition = {
1515
'(',
1616
printSeparatedList(path.map(print, 'arguments')),
1717
')',
18-
group(
19-
printSeparatedItem(
20-
concat([
21-
'->',
22-
printSeparatedList(path.map(print, 'returnArguments'), {
23-
firstSeparator: line,
24-
lastSeparator: ''
25-
})
26-
]),
27-
{ firstSeparator: line }
28-
)
29-
),
18+
node.returnArguments.length === 0
19+
? ' '
20+
: group(
21+
printSeparatedItem(
22+
concat([
23+
'->',
24+
printSeparatedList(path.map(print, 'returnArguments'), {
25+
firstSeparator: line,
26+
lastSeparator: ''
27+
})
28+
]),
29+
{ firstSeparator: line }
30+
)
31+
),
3032
path.call(print, 'body')
3133
])
3234
};

tests/Assembly/Assembly.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,13 @@ assembly{
138138
three:
139139
}
140140
}
141+
142+
function assemblyFunctionNoReturn () {
143+
144+
assembly {
145+
146+
function $somefn(somearg) {
147+
}
148+
}
149+
}
141150
}

tests/Assembly/__snapshots__/jsfmt.spec.js.snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ assembly{
141141
three:
142142
}
143143
}
144+
145+
function assemblyFunctionNoReturn () {
146+
147+
assembly {
148+
149+
function $somefn(somearg) {
150+
}
151+
}
152+
}
144153
}
145154
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146155
contract Assembly {
@@ -319,6 +328,14 @@ contract Assembly {
319328
three:
320329
}
321330
}
331+
332+
function assemblyFunctionNoReturn() {
333+
assembly {
334+
function $somefn(somearg) {
335+
336+
}
337+
}
338+
}
322339
}
323340
324341
`;

0 commit comments

Comments
 (0)