Skip to content

Commit 4cd5412

Browse files
authored
we check if the last character is a ')' to catch function calls without parameters (#239)
1 parent a5bb07f commit 4cd5412

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

src/nodes/AssemblyCall.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const {
77
const printList = require('./print-list');
88

99
const AssemblyCall = {
10-
print: ({ node, path, print }) =>
11-
node.arguments.length === 0
10+
print: ({ node, path, print, options }) =>
11+
node.arguments.length === 0 &&
12+
options.originalText.charAt(options.locEnd(node)) !== ')'
1213
? node.functionName
1314
: concat([
1415
node.functionName,

src/printer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ function genericPrint(path, options, print) {
1212
}
1313

1414
if (hasNodeIgnoreComment(node)) {
15-
return options.originalText.slice(node.range[0], node.range[1] + 1);
15+
return options.originalText.slice(
16+
options.locStart(node),
17+
options.locEnd(node) + 1
18+
);
1619
}
1720

1821
return nodes[node.type].print({ node, options, path, print });

tests/Assembly/Assembly.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
101101
}
102102
}
103103

104+
function assemblyNoParameterCalls() {
105+
assembly {
106+
call(gas(), to, value, inputData, inputDataSize, 0, 0)
107+
}
108+
}
109+
104110
function assemblyLabels() {
105111
assembly {
106112
let n := calldataload(4)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
104104
}
105105
}
106106
107+
function assemblyNoParameterCalls() {
108+
assembly {
109+
call(gas(), to, value, inputData, inputDataSize, 0, 0)
110+
}
111+
}
112+
107113
function assemblyLabels() {
108114
assembly {
109115
let n := calldataload(4)
@@ -269,6 +275,12 @@ contract Assembly {
269275
}
270276
}
271277
278+
function assemblyNoParameterCalls() {
279+
assembly {
280+
call(gas(), to, value, inputData, inputDataSize, 0, 0)
281+
}
282+
}
283+
272284
function assemblyLabels() {
273285
assembly {
274286
let n := calldataload(4)

0 commit comments

Comments
 (0)