reduce error clutter for undefined symbols

This commit is contained in:
Irmen de Jong 2025-01-03 01:55:44 +01:00
parent b014facbd3
commit 45fe1bb16e
2 changed files with 13 additions and 1 deletions

View File

@ -33,6 +33,19 @@ internal class ErrorReporter(val colors: IConsoleColors): IErrorReporter {
var numErrors = 0
var numWarnings = 0
var numInfos = 0
// For undefined symbol errors, remove all other errors and warnings on the same source line,
// because those are very likely caused by the unknown symbol. This reduces error clutter.
val undefinedSymbolErrors = messages.filter { it.severity == MessageSeverity.ERROR && it.message.contains("undefined symbol") }
for(e in undefinedSymbolErrors) {
messages.removeIf {
it !== e
&& (it.severity == MessageSeverity.WARNING || it.severity == MessageSeverity.ERROR)
&& it.position.file == e.position.file
&& it.position.line == e.position.line
}
}
messages.sortedWith(compareBy({it.position.file}, {it.position.line}, {it.severity})).forEach {
val printer = when(it.severity) {
MessageSeverity.INFO -> System.out

View File

@ -10,7 +10,6 @@ TODO
Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^
- reduce the number of collateral errors reported for undefined symbols
- Kotlin: can we use inline value classes in certain spots?
- Improve the SublimeText syntax file for prog8, you can also install this for 'bat': https://github.com/sharkdp/bat?tab=readme-ov-file#adding-new-syntaxes--language-definitions