Skip to content

Commit

Permalink
feat(enum): Enum can now have patterns, userdata, void and ranges as …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
giann committed May 31, 2024
1 parent 0b9158c commit fb26dc8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ pub fn isConstant(self: Self, node: Node.Index) bool {
.Void,
.Namespace,
=> true,

.AsyncCall,
.Block,
.Break,
Expand Down Expand Up @@ -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),
Expand Down
9 changes: 8 additions & 1 deletion src/Codegen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fb26dc8

Please sign in to comment.