Fix parsing crash when return is void

logical-or-coverage
cgewecke 5 years ago
parent 9844e674f5
commit 57ce8cbeb6
  1. 1
      lib/parse.js
  2. 7
      test/sources/solidity/contracts/return/empty-return.sol
  3. 5
      test/units/expressions.js

@ -190,6 +190,7 @@ parse.SourceUnit = function(contract, expression) {
parse.ReturnStatement = function(contract, expression) {
register.statement(contract, expression);
expression.expression &&
parse[expression.expression.type] &&
parse[expression.expression.type](contract, expression.expression, true);
};

@ -0,0 +1,7 @@
pragma solidity ^0.5.0;
contract Test {
function a(uint x) public pure {
return;
}
}

@ -16,4 +16,9 @@ describe('generic expressions / misc', () => {
const info = util.instrumentAndCompile('return/return');
util.report(info.solcOutput.errors);
});
it('should compile after instrumenting function the returns void', () => {
const info = util.instrumentAndCompile('return/empty-return');
util.report(info.solcOutput.errors);
});
});

Loading…
Cancel
Save