Skip to content

Commit

Permalink
fix(repl): Allo lone list/map expression in global space if REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Oct 21, 2023
1 parent dc5d707 commit d3e75ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3042,7 +3042,7 @@ pub const Parser = struct {
}

fn listDeclaration(self: *Self, constant: bool) !*ParseNode {
if (self.check(.Less) and self.current.?.scope_depth > 0) {
if (self.check(.Less) and (self.current.?.scope_depth > 0 or self.current.?.function_node.node.type_def.?.resolved_type.?.Function.function_type == .Repl)) {
// Its a list expression
return try self.expressionStatement(true);
}
Expand Down Expand Up @@ -3080,7 +3080,7 @@ pub const Parser = struct {
}

fn mapDeclaration(self: *Self, constant: bool) !*ParseNode {
if (self.check(.Less) and self.current.?.scope_depth > 0) {
if (self.check(.Less) and (self.current.?.scope_depth > 0 or self.current.?.function_node.node.type_def.?.resolved_type.?.Function.function_type == .Repl)) {
// Its a map expression
return try self.expressionStatement(true);
}
Expand Down

0 comments on commit d3e75ef

Please sign in to comment.