From fb26dc86b56181ad7680a408fbbb95fa0622d252 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 29 May 2024 14:52:24 +0200 Subject: [PATCH] feat(enum): Enum can now have patterns, userdata, void and ranges as value --- CHANGELOG.md | 10 ++++++++++ src/Ast.zig | 2 ++ src/Codegen.zig | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 483e173c..82181783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Unreleased +## Added +- Enum can now have `rg`, `ud`, `void`, `pat` has value type +- Object can have `const` properties (https://github.com/buzz-language/buzz/issues/13). A object with only `const` properties is considered itself `const`. Although we don't do anything yet with that concept. https://github.com/buzz-language/buzz/issues/114 is the objective but it requires being able to build objects and instances at compile time which is not yet possible. + +## Modified + +## Fixed +- Type checking was not done on object instance property assignments +- Http client could not be collected because it kept connection opened to previous requests' domains + # 0.4.0 (05-16-2024) ## Added diff --git a/src/Ast.zig b/src/Ast.zig index a8f3e8b3..7ca5e856 100644 --- a/src/Ast.zig +++ b/src/Ast.zig @@ -738,6 +738,7 @@ pub fn isConstant(self: Self, node: Node.Index) bool { .Void, .Namespace, => true, + .AsyncCall, .Block, .Break, @@ -767,6 +768,7 @@ pub fn isConstant(self: Self, node: Node.Index) bool { .BlockExpression, .Out, => false, + .As => self.isConstant(self.nodes.items(.components)[node].As.left), .Is => self.isConstant(self.nodes.items(.components)[node].Is.left), .Range => self.isConstant(self.nodes.items(.components)[node].Range.low) and self.isConstant(self.nodes.items(.components)[node].Range.high), diff --git a/src/Codegen.zig b/src/Codegen.zig index 6079d4dd..3d0aa5b1 100644 --- a/src/Codegen.zig +++ b/src/Codegen.zig @@ -1702,7 +1702,14 @@ fn generateEnum(self: *Self, node: Ast.Node.Index, _: ?*Breaks) Error!?*obj.ObjF } switch (enum_type.def_type) { - .String, .Integer, .Float => {}, + .String, + .Integer, + .Float, + .Pattern, + .UserData, + .Void, + .Range, + => {}, else => { self.reporter.reportErrorAt( .syntax,