redhat-developer / redhat-developer/vscode-java
If there's a syntax error inside an arrow function, the entire function is highlighted as an error in the editor
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 546
- Avg merge
- 20h 1m
- Merged PRs (30d)
- 11
Description
When an arrow function is assigned to a variable with a generic type parameter, and there is a syntax error inside the arrow function, VSCode highlights the entire arrow function as an error. This obscures the location of the syntax error and makes the code difficult to read.
Environment
Version: 1.54.3 (user setup)
Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
Date: 2021-03-15T10:55:45.459Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.18362
Steps To Reproduce
Repository: https://github.com/AnthonyWeston/java-test
- Add an arrow function with an undefined variable name inside it, and assign the function to a variable with a generic type parameter:
List<Integer> test = Stream.of("1", "2", "3")
.map(s -> {
int result = Integer.parseInt(s);
return oops;
})
.collect(Collectors.toList());
});
Current Result
VSCode highlights the entire arrow function as an error, obscuring the location of the undefined variable and making the code difficult to read. The error message is "Cannot infer type argument(s) for map(Function<? super T,? extends R>)"

Expected Result
Only the variable assignment is highlighted as an error, and the undefined variable is highlighted as an error and clearly visible.
Additional Information
Logs: https://github.com/AnthonyWeston/java-test/blob/main/log.log
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the linked java-test repository and the provided arrow-function example to reproduce the diagnostic highlighting in VS Code. Compare the current and expected diagnostics, including the undefined variable inside the arrow function; done means the syntax error is localized instead of the entire function being highlighted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100