Skip to content

Commit 5a2d002

Browse files
authored
Handle let expressions without values (#316)
1 parent d3635b5 commit 5a2d002

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/nodes/AssemblyLocalDefinition.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ const {
77
const printSeparatedList = require('./print-separated-list');
88

99
const AssemblyLocalDefinition = {
10-
print: ({ path, print }) =>
11-
concat([
10+
print: ({ node, path, print }) => {
11+
const parts = [
1212
'let',
13-
printSeparatedList(path.map(print, 'names'), { firstSeparator: line }),
14-
':= ',
15-
path.call(print, 'expression')
16-
])
13+
printSeparatedList(path.map(print, 'names'), { firstSeparator: line })
14+
];
15+
16+
if (node.expression !== null) {
17+
parts.push(':= ');
18+
parts.push(path.call(print, 'expression'));
19+
}
20+
21+
return concat(parts);
22+
}
1723
};
1824

1925
module.exports = AssemblyLocalDefinition;

tests/Assembly/Assembly.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,9 @@ function $somefn(somearg) {
147147
}
148148
}
149149
}
150+
151+
function letWithoutValue ( ) {
152+
153+
assembly { let result }
154+
}
150155
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ function $somefn(somearg) {
150150
}
151151
}
152152
}
153+
154+
function letWithoutValue ( ) {
155+
156+
assembly { let result }
157+
}
153158
}
154159
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155160
contract Assembly {
@@ -336,6 +341,12 @@ contract Assembly {
336341
}
337342
}
338343
}
344+
345+
function letWithoutValue() {
346+
assembly {
347+
let result
348+
}
349+
}
339350
}
340351
341352
`;

0 commit comments

Comments
 (0)