Skip to content

Add support for var variable declarations#3821

Open
Drodt wants to merge 3 commits into
mainfrom
ty-inference
Open

Add support for var variable declarations#3821
Drodt wants to merge 3 commits into
mainfrom
ty-inference

Conversation

@Drodt

@Drodt Drodt commented Jun 10, 2026

Copy link
Copy Markdown
Member

Intended Change

Allows parsing of declarations with type inference, e.g.:

var x = 0;

These declarations are converted to declarations with explicit types. The declaration above is translated to

int x = 0;

This change required adding the Java10PostProcessor to our JavaParser instances. No additional taclets are necessary.

Type of pull request

  • New feature (non-breaking change which adds functionality)
  • There are changes to the (Java) code

Ensuring quality

  • I made sure that introduced/changed code is well documented (javadoc and inline comments).
  • I made sure that new/changed end-user features are well documented (https://github.com/KeYProject/key-docs).
  • I added new test case(s) for new functionality.

Additional information and contact(s)

The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.

@Drodt Drodt added Feature New feature or request Java Parser Java Pull requests that update Java code labels Jun 10, 2026
@wadoon

wadoon commented Jun 11, 2026

Copy link
Copy Markdown
Member

Did you also test it with referenced types? Parameterized types are currently out of reach.

The hardest thing should be: var x = b ? new String() : 2

@Drodt

Drodt commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

That example leads to an UnsupportedOperationException in JavaParser.

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

Labels

Feature New feature or request Java Parser Java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants