diff --git a/compiler/src/prog8/compiler/ErrorReporter.kt b/compiler/src/prog8/compiler/ErrorReporter.kt index 6439d61c6..63e10ff41 100644 --- a/compiler/src/prog8/compiler/ErrorReporter.kt +++ b/compiler/src/prog8/compiler/ErrorReporter.kt @@ -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 diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 77cab968b..97d3e0ee9 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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