Skip to content

Fix potential bug IntelliJ warnings - #126

Merged
andreaTP merged 5 commits into
bytecodealliance:mainfrom
Marcono1234:bug-intellij-warnings
Sep 15, 2026
Merged

andreaTP merged 5 commits into
bytecodealliance:mainfrom
Marcono1234:bug-intellij-warnings

Conversation

@Marcono1234

@Marcono1234 Marcono1234 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Based on #124; please only consider the commits exclusive to this PR here, currently ddd98df
(in the GitHub UI on the "Files changed" tab you can click "All commits" on the top left to select specific commits)

I had a look at some of the warnings IntelliJ reported for the project, and it seems some of them might be legitimate bugs. Have added comments below. Please let me know what you think.

I mainly wanted to highlight these potential issues; please let me know if I should split the PR or if you want to use it as reference and fix the issues yourself.

@Marcono1234 Marcono1234 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@andreaTP, already pinging you for feedback1 (once you have time; no hurry). Though I will keep this PR as draft for now.

Footnotes

  1. Because this is a Draft you would otherwise not be notified.

Comment thread build-time-compiler/src/main/java/run/endive/build/time/compiler/Generator.java Outdated
Comment thread cli/src/main/java/run/endive/experimental/cli/Cli.java
Comment on lines +1509 to 1512
// Intentionally get the result as 32 bit `int` (despite it being converted to `long` when
// pushed to the stack)
//noinspection IntegerMultiplicationImplicitCastToLong
stack.push(v << c);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IntelliJ was warning that because v and c are int, the result is an int as well and could overflow before it is implicitly converted to long when pushed on the stack.

I assume that is intended here though since this is an operation for i32? Not completely sure though.

Comment thread simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
Comment thread simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
Comment thread simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
Comment thread simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
Comment thread simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java
Comment thread wasm/src/main/java/run/endive/wasm/Parser.java
@andreaTP
andreaTP force-pushed the bug-intellij-warnings branch from ddd98df to 7842962 Compare July 27, 2026 13:39

@andreaTP andreaTP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like good improvements!

I rebased on latest main and found a couple of minor things, added 2 commits on top for you to review @Marcono1234

@Marcono1234 Marcono1234 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your additional changes (and for fixing an issue I had made)! Sorry for the late follow-up.

I noticed one more thing (see comment below); should that be adjusted as well?

Comment on lines 1307 to 1311
private static void I32_MUL(MStack stack) {
var a = stack.pop();
var b = stack.pop();
stack.push(a * b);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe I32_MUL here is missing (int) casts for the stack operands? All other I32_... methods seem to have that.

Marcono1234 and others added 3 commits September 15, 2026 12:53
The previous commit changed parse(wasmBytes) to
parse(() -> new ByteArrayInputStream(wasmBytes)), switching from the
static method (which ignores builder config) to the instance method
(which applies includeSectionId(CODE)). Parsing only the CODE section
causes validation to fail with "function and code section have
inconsistent lengths".

Use the static Parser.parse(wasmBytes) directly since the builder
config was never actually applied and the method needs multiple
sections (CODE, FUNCTION, IMPORT).
The previous commit simplified lt(float, float) to "return a <= b"
instead of "return a < b", making it identical to le (less-than-or-equal).
@andreaTP
andreaTP force-pushed the bug-intellij-warnings branch from 0e30301 to b5a2403 Compare September 15, 2026 11:53
@andreaTP
andreaTP force-pushed the bug-intellij-warnings branch from b5a2403 to dd837cf Compare September 15, 2026 13:38
@andreaTP
andreaTP marked this pull request as ready for review September 15, 2026 13:38

@andreaTP andreaTP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@andreaTP
andreaTP merged commit cd5b524 into bytecodealliance:main Sep 15, 2026
44 of 45 checks passed
@Marcono1234
Marcono1234 deleted the bug-intellij-warnings branch September 15, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants