From 2ab20652f83c248e85e0f2d38482ac0a1761b40d Mon Sep 17 00:00:00 2001 From: nub31 Date: Tue, 10 Mar 2026 17:53:42 +0100 Subject: [PATCH] ... --- compiler/Generator.cs | 2 +- compiler/TypeChecker.cs | 4 ++-- examples/program/main.nub | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/Generator.cs b/compiler/Generator.cs index ab88d2f..f76e8ad 100644 --- a/compiler/Generator.cs +++ b/compiler/Generator.cs @@ -721,7 +721,7 @@ static inline string *string_from_cstr(char *cstr) if (value != null) writer.WriteLine($", .{enumVariantType.Variant} = {value} }};"); else - writer.WriteLine(" }};"); + writer.WriteLine(" };"); return name; } diff --git a/compiler/TypeChecker.cs b/compiler/TypeChecker.cs index 1eaf701..fa59e9e 100644 --- a/compiler/TypeChecker.cs +++ b/compiler/TypeChecker.cs @@ -672,10 +672,10 @@ public class TypeChecker throw BasicError($"Enum '{variantType.EnumType}' does not have a variant named '{variantType.Variant}'", expression.Type); if (expression.Value == null && variant.Type is not null) - throw BasicError($"Enum variant '{variantType.EnumType}' expects a value of type '{variant.Type}'", expression.Type); + throw BasicError($"Enum variant '{variantType}' expects a value of type '{variant.Type}'", expression.Type); if (expression.Value != null && variant.Type is null) - throw BasicError($"Enum variant '{variantType.EnumType}' does not expect any data", expression.Value); + throw BasicError($"Enum variant '{variantType}' does not expect any data", expression.Value); var value = expression.Value == null ? null : CheckExpression(expression.Value, variant.Type); diff --git a/examples/program/main.nub b/examples/program/main.nub index a50b13a..cef6d98 100644 --- a/examples/program/main.nub +++ b/examples/program/main.nub @@ -11,12 +11,16 @@ enum Message { } func main(): i32 { - let messages: []Message = [new Message::Say("first"), new Message::Say("second")] + let messages: []Message = [new Message::Say("first"), new Message::Quit] for message in messages { match message { - Say msg core::println(msg) - Quit {} + Say msg { + core::println(msg) + } + Quit { + core::println("quit") + } } }