degory / ghul

compiler for the ghūl programming language
https://ghul.dev
GNU Affero General Public License v3.0
4 stars 0 forks source link

Casting an error value can cause an internal error #1081

Open degory opened 9 months ago

degory commented 9 months ago

A cast expression with an error value right hand side can result in an internal error

For example, the following produces no visible error from the language extension, but encounters an internal error on dotnet build due to generation of a dummy value. At no point is the actual root cause reported, which is an undefined symbol within the cast expression right hand side:

// interpolation_handler is undefined, but the rest of the statement is valid: 
_constructor = cast Semantic.Symbols.FUNCTION_GROUP(interpolation_handler.find_member("init")).functions |
    .filter(f => f.arguments.count == 2)
    .only();

Internal error on dotnet build is

suppress fatal diagnostic: FATAL C:\Users\degory\src\ghul\src\syntax\process\generate_il.ghul 81,65..81,105 generated dummy value: Semantic.Symbol
  s.FUNCTION_GROUP from C:\Users\degory\src\ghul\src\syntax\process\generate_il.ghul 81,65..81,105
  internal compiler error