Skip to content

Commit 0e9d908

Browse files
committed
add js async mark on let bind; tag 0.9.10
1 parent 23ef089 commit 0e9d908

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "calcit"
3-
version = "0.9.9"
3+
version = "0.9.10"
44
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
55
edition = "2024"
66
license = "MIT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Read more in [Respo Calcit Workflow](https://github.com/calcit-lang/respo-calcit
100100

101101
```cirru
102102
{}
103-
:calcit-version |0.9.9
103+
:calcit-version |0.9.10
104104
:dependencies $ {}
105105
|calcit-lang/memof |0.0.11
106106
|calcit-lang/lilac |main

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@calcit/procs",
3-
"version": "0.9.9",
3+
"version": "0.9.10",
44
"main": "./lib/calcit.procs.mjs",
55
"devDependencies": {
66
"@types/node": "^22.10.7",

src/codegen/emit_js.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,23 @@ fn quote_to_js(xs: &Calcit, var_prefix: &str, tags: &RefCell<HashSet<EdnTag>>) -
189189
}
190190
}
191191

192-
fn make_let_with_bind(left: &str, right: &str, body: &str) -> String {
193-
format!("(function __bind__({left}){{\n{body} }})({right})")
192+
fn make_let_with_bind(left: &str, right: &str, body: &str, has_await: bool) -> String {
193+
let (await_mark, async_mark) = if has_await {
194+
("await ", "async ")
195+
} else {
196+
("", "")
197+
};
198+
format!("{await_mark}({async_mark}function __bind__({left}){{\n{body} }})({right})")
199+
194200
}
195201

196-
fn make_let_with_wrapper(left: &str, right: &str, body: &str) -> String {
197-
format!("(function __let__(){{ \nlet {left} = {right};\n {body} }})()")
202+
fn make_let_with_wrapper(left: &str, right: &str, body: &str, has_await: bool) -> String {
203+
let (await_mark, async_mark) = if has_await {
204+
("await ", "async ")
205+
} else {
206+
("", "")
207+
};
208+
format!("{await_mark}({async_mark}function __let__(){{ \nlet {left} = {right};\n {body} }})()")
198209
}
199210

200211
fn make_fn_wrapper(body: &str, is_async: bool) -> String {
@@ -762,9 +773,9 @@ fn gen_let_code(
762773

763774
// first variable is using conflicted name
764775
let ret = if local_defs.contains(sym) {
765-
make_let_with_bind(&left, &right, &body_part)
776+
make_let_with_bind(&left, &right, &body_part, has_await)
766777
} else {
767-
make_let_with_wrapper(&left, &right, &body_part)
778+
make_let_with_wrapper(&left, &right, &body_part, has_await)
768779
};
769780
return match base_return_label {
770781
Some(label) => Ok(format!("{label}{ret}")),

0 commit comments

Comments
 (0)