ForNeVeR / ForNeVeR/Cesium

Compiler errors should not be rendered as exceptions

Open
#998 0 comments 0 reactions 0 assignees View on GitHub
area:sdk kind:feature status:help-wanted
Dominant language
C#
Stars
451
Forks
49
Avg merge
13h 59m
Merged PRs (30d)
6

Description

Properly formed errors should be errors, not exceptions with full stack trace.

Example I've got from Cesium SDK:
```
0>------- Started building project: Tabularius.Interop.Dto
CONSOLE: Generating assembly "obj\Debug\net10.0\Tabularius.Interop.Dto.dll".
CONSOLE: Processing source file "G:\Projects\tabularius\Tabularius.Interop.Dto\lib.c".
CONSOLE: Unhandled exception. Cesium.Core.CompilationException: Cannot resolve type Quantity
CONSOLE: at Cesium.CodeGen.Contexts.TranslationUnitContext.ResolveType(IType type, ImmutableArray`1 resolutionStack) in /_/Cesium.CodeGen/Contexts/TranslationUnitContext.cs:line 187
CONSOLE: at Cesium.CodeGen.Contexts.TranslationUnitContext.<>c__DisplayClass35_1.b__2(LocalDeclarationInfo structMember) in /_/Cesium.CodeGen/Contexts/TranslationUnitContext.cs:line 264
CONSOLE: at System.Linq.Enumerable.ListSelectIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
CONSOLE: at System.Linq.Enumerable.ListSelectIterator`2.ToList()
CONSOLE: at Cesium.CodeGen.Contexts.TranslationUnitContext.<>c__DisplayClass35_0.g__ResolveStructMembers|0(StructType structType) in /_/Cesium.CodeGen/Contexts/TranslationUnitContext.cs:line 261
CONSOLE: at Cesium.CodeGen.Contexts.TranslationUnitContext.ResolveType(IType type, ImmutableArray`1 resolutionStack) in /_/Cesium.CodeGen/Contexts/TranslationUnitContext.cs:line 237
CONSOLE: at Cesium.CodeGen.Contexts.TranslationUnitContext.ResolveType(IType type) in /_/Cesium.CodeGen/Contexts/TranslationUnitContext.cs:line 180
CONSOLE: at Cesium.CodeGen.Contexts.GlobalConstructorScope.ResolveType(IType type) in /_/Cesium.CodeGen/Contexts/GlobalConstructorScope.cs:line 63
CONSOLE: at Cesium.CodeGen.Ir.Lowering.BlockItemLowering.Lower(IDeclarationScope scope, IBlockItem blockItem)
CONSOLE: at Cesium.CodeGen.Ir.Lowering.BlockItemLowering.LowerDeclaration(IDeclarationScope scope, IBlockItem blockItem) in /_/Cesium.CodeGen/Ir/Lowering/BlockItemLowering.cs:line 75
CONSOLE: at Cesium.CodeGen.Contexts.AssemblyContext.<>c__DisplayClass29_0.b__0(IBlockItem node) in /_/Cesium.CodeGen/Contexts/AssemblyContext.cs:line 68
CONSOLE: at System.Linq.Enumerable.IteratorSelectIterator`2.ToListNoPresizing()
CONSOLE: at System.Linq.Enumerable.IteratorSelectIterator`2.ToList()
CONSOLE: at Cesium.CodeGen.Contexts.AssemblyContext.EmitTranslationUnit(String name, TranslationUnit translationUnit) in /_/Cesium.CodeGen/Contexts/AssemblyContext.cs:line 68
CONSOLE: at Cesium.Compiler.Compilation.GenerateCode(AssemblyContext context, AbsolutePath inputFile) in /_/Cesium.Compiler/Compilation.cs:line 165
CONSOLE: at Cesium.Compiler.Compilation.Compile(IEnumerable`1 inputFilePaths, LocalPath outputFile, CompilationOptions compilationOptions) in /_/Cesium.Compiler/Compilation.cs:line 82
CONSOLE: at Cesium.Compiler.Program.<>c.<b__0_0>d.MoveNext() in /_/Cesium.Compiler/Main.cs:line 62
CONSOLE: --- End of stack trace from previous location ---
CONSOLE: at Cesium.Compiler.CommandLineParser.<>c__DisplayClass0_0.<b__1>d.MoveNext() in /_/Cesium.Compiler/CommandLineParser.cs:line 41
CONSOLE: --- End of stack trace from previous location ---
CONSOLE: at Cesium.Compiler.CommandLineParser.ParseCommandLineArgs(String[] args, ICompilerReporter reporter, Func`2 worker) in /_/Cesium.Compiler/CommandLineParser.cs:line 22
CONSOLE: at Cesium.Compiler.Program.Main(String[] args) in /_/Cesium.Compiler/Main.cs:line 18
CONSOLE: at Cesium.Compiler.Program.(String[] args)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the unresolved-type case shown in the issue, then start with the error flow through Cesium.Compiler/Main.cs, CommandLineParser.cs, and Compilation.cs. Trace how CompilationException reaches the command-line reporter and adjust the handling so a properly formed compiler error is reported without a full exception stack trace. Done means the diagnostic remains visible while the stack trace is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.