Skip to content

Improve model-building error messages - #1109

Open
asotona wants to merge 6 commits into
openjdk:code-reflectionfrom
asotona:improve-diagnostics
Open

Improve model-building error messages#1109
asotona wants to merge 6 commits into
openjdk:code-reflectionfrom
asotona:improve-diagnostics

Conversation

@asotona

@asotona asotona commented Jul 21, 2026

Copy link
Copy Markdown
Member

This PR improves model-building error messages and provides additional diagnostic information, including model fragments. It also enables incomplete models to be printed.

Example of the improved error message:

Use of value is not dominated by value
^block_1:
  %1 : java.type:"int" = constant @10;
  %2 : java.type:"int" = constant @11;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value declared here
  %3 : java.type:"int" = neg %2;
  branch ^block_3;
^block_5:
  %7 : java.type:"int" = constant @30;
  %8 : java.type:"int" = neg %2;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ invalid use
  return;

See TestDiagnostics for more.



Progress

  • Change must not contain extraneous whitespace

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/babylon.git pull/1109/head:pull/1109
$ git checkout pull/1109

Update a local copy of the PR:
$ git checkout pull/1109
$ git pull https://git.openjdk.org/babylon.git pull/1109/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1109

View PR using the GUI difftool:
$ git pr show -t 1109

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/babylon/pull/1109.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jul 21, 2026

Copy link
Copy Markdown

👋 Welcome back asotona! A progress list of the required criteria for merging this PR into code-reflection will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jul 21, 2026

Copy link
Copy Markdown

@asotona This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

Improve model-building error messages

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the code-reflection branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the code-reflection branch, type /integrate in a new comment.

@openjdk openjdk Bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 21, 2026
@mlbridge

mlbridge Bot commented Jul 21, 2026

Copy link
Copy Markdown

Webrevs

@PaulSandoz PaulSandoz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very good, something I think we can iterate on. Two things:

  1. I wonder if we should have an internal option in OpWriter to enable the modified behavior, otherwise it can behave strangely. And it seems useful to consolidate catching of exceptions within some general lambda accepting method.
  2. I think we need to be very consistent in reusing the terminology in the API documentation.

assertEquals("""
Block has no terminating operation as the last operation
^block_0:
^~~~~~~~ missing terminal op

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
^~~~~~~~ missing terminal op
^~~~~~~~ missing terminating op

^block_0:
^~~~~~~~ missing terminal op
%0 : java.type:"int" = constant @1;
""", assertThrows(IllegalStateException.class, () -> func("f", body)).getMessage());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you place the lambda on the next line? as it makes it easier to scan

assertEquals("""
A new operation cannot directly use a value from a completed code model
^block_0(%0 : java.type:"int"):
^~ value from completed model

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we reuse the same terminology in the error message? i.e. the value's declaring block is built, since "completed model" is not a phrase we use. This applies in other cases too when a block is unobservable (since it is still being built).

assertEquals("""
Body of operation is connected to a different ancestor body
^block_1:
^~~~~~~~ operation body

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we referring to the operation's ancestor body or its parent block?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants