Skip to content

Commit deb25c5

Browse files
committed
fix: correct an error preventing reading data from a channel with the corresponding '<-' operator
1 parent 48466d0 commit deb25c5

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

argon/lang/compiler2/compiler2.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,9 @@ void Compiler::CompilePrefix(const node::Unary *unary) {
17891789
this->Expression((const node::Node *) unary->value);
17901790

17911791
switch (unary->token_type) {
1792+
case scanner::TokenType::ARROW_LEFT:
1793+
this->unit_->Emit(vm::OpCode::POPC, &unary->loc);
1794+
break;
17921795
case scanner::TokenType::EXCLAMATION:
17931796
this->unit_->Emit(vm::OpCode::NOT, &unary->loc);
17941797
break;

argon/lang/parser2/node/node.h

-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ namespace argon::lang::parser2::node {
2929
AWAIT,
3030
BLOCK,
3131
CALL,
32-
CHAN_IN,
33-
CHAN_OUT,
34-
DEFER,
3532
DICT,
3633
ELVIS,
3734
EXPRESSION,
@@ -74,7 +71,6 @@ namespace argon::lang::parser2::node {
7471
TRAIT,
7572
TRAP,
7673
TUPLE,
77-
UNARY,
7874
UPDATE,
7975
VARDECL,
8076
YIELD

argon/lang/parser2/parser2.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ Node *Parser::ParseChanOut(Context *context) {
18661866

18671867
auto expr = this->ParseExpression(context, PeekPrecedence(TokenType::ARROW_LEFT));
18681868

1869-
auto *unary = NewNode<Unary>(type_ast_unary_, false, NodeType::CHAN_OUT);
1869+
auto *unary = NewNode<Unary>(type_ast_prefix_, false, NodeType::PREFIX);
18701870
if (unary == nullptr) {
18711871
Release(expr);
18721872

@@ -1875,6 +1875,7 @@ Node *Parser::ParseChanOut(Context *context) {
18751875

18761876
unary->loc.start = start;
18771877
unary->loc.end = expr->loc.end;
1878+
unary->token_type = TokenType::ARROW_LEFT;
18781879

18791880
unary->value = (ArObject *) expr;
18801881

@@ -2783,7 +2784,7 @@ Node *Parser::ParseWalrus(Context *context, node::Node *left) {
27832784
throw ParserException(itm->loc, kStandardError[29], ":=");
27842785
}
27852786

2786-
ListAppend(list, ((const node::Unary*) itm)->value);
2787+
ListAppend(list, ((const node::Unary *) itm)->value);
27872788
}
27882789

27892790
multi = true;

0 commit comments

Comments
 (0)