Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid generating empty statement in receiveI64ParamAsI53 #21487

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,14 @@ function defineI64Param(name) {


function receiveI64ParamAsI53(name, onError, handleErrors = true) {
var errorHandler = handleErrors ? `if (isNaN(${name})) return ${onError}` : '';
var errorHandler = handleErrors ? `if (isNaN(${name})) { return ${onError}; }` : '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the extra braces needed here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, I just thought it felt safer in code that's being pasted together. Like, in case onError has a semicolon in it or something. Should get minified so it seems OK.

if (WASM_BIGINT) {
// Just convert the bigint into a double.
return `${name} = bigintToI53Checked(${name});${errorHandler};`;
return `${name} = bigintToI53Checked(${name});${errorHandler}`;
}
// Convert the high/low pair to a Number, checking for
// overflow of the I53 range and returning onError in that case.
return `var ${name} = convertI32PairToI53Checked(${name}_low, ${name}_high);${errorHandler};`;
return `var ${name} = convertI32PairToI53Checked(${name}_low, ${name}_high);${errorHandler}`;
}

function receiveI64ParamAsI53Unchecked(name) {
Expand Down
Loading