Skip to content

Commit faa0c91

Browse files
committed
fix: an async generator code gen issue
If an assign node's expr contains any awaits, the await code gen shall hapen before the left symbol resolution, or the symbol may not dominant all uses. This fix simply fix this issue by resolve symbol twice, this is, of cource, ugly, but it's the simplest way I can think of.
1 parent 8c7eca7 commit faa0c91

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

planglib/std/task/http.pi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl HttpClient {
4545
let ip = await resolver.resolve_async(domain);
4646
let status = await self.socket.connect_async(ip, 80 as i32);
4747
// 发送请求
48-
await self.socket.write_async(bytes);
48+
status = await self.socket.write_async(bytes);
4949

5050
// 使用1k缓冲区读取header
5151
let response_buf = [u8*1024;];

src/ast/node/statement.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,19 +587,19 @@ impl Node for AssignNode {
587587
return Err(ctx.add_diag(self.var.range().new_err(ErrorCode::NOT_ASSIGNABLE)));
588588
}
589589
let rel = rel.unwrap();
590-
let ptr = rel.get_value();
591590
let lpltype = rel.get_ty();
592591
// 要走转换逻辑,所以不和下方分支统一
593592
let value = ctx
594-
.emit_with_expectation(
595-
&mut self.exp,
596-
lpltype.clone(),
597-
self.var.range(),
598-
builder,
599-
)?
593+
.emit_with_expectation(&mut self.exp, lpltype.clone(), var.range(), builder)?
600594
.get_value()
601595
.unwrap()
602596
.get_value();
597+
let rel = var.emit(ctx, builder)?.get_value();
598+
if rel.is_none() {
599+
return Err(ctx.add_diag(self.var.range().new_err(ErrorCode::NOT_ASSIGNABLE)));
600+
}
601+
let rel = rel.unwrap();
602+
let ptr = rel.get_value();
603603
if rel.is_const() {
604604
return Err(ctx.add_diag(self.range.new_err(ErrorCode::ASSIGN_CONST)));
605605
}

0 commit comments

Comments
 (0)