diff --git a/Cargo.lock b/Cargo.lock index f2039f77a..a0b67f418 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -514,6 +514,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chacha20" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "rand_core 0.10.1", +] + [[package]] name = "chromiumoxide" version = "0.9.1" @@ -1544,8 +1555,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 6.0.0", + "rand_core 0.10.1", + "wasm-bindgen", ] [[package]] @@ -2588,7 +2602,7 @@ dependencies = [ "codspeed-divan-compat", "csv", "dirs 6.0.0", - "getrandom 0.3.4", + "getrandom 0.4.3", "hcl-rs", "itertools 0.15.0", "md5", @@ -2600,7 +2614,7 @@ dependencies = [ "percent-encoding", "proptest", "quick-xml", - "rand", + "rand 0.10.2", "regex-lite", "ropey", "rstest", @@ -3053,7 +3067,7 @@ dependencies = [ "opentelemetry", "percent-encoding", "portable-atomic", - "rand", + "rand 0.9.4", "thiserror 2.0.18", "tokio", "tokio-stream", @@ -3337,7 +3351,7 @@ dependencies = [ "bit-vec", "bitflags", "num-traits", - "rand", + "rand 0.9.4", "rand_chacha", "rand_xorshift", "regex-syntax", @@ -3423,7 +3437,7 @@ dependencies = [ "bytes", "getrandom 0.3.4", "lru-slab", - "rand", + "rand 0.9.4", "ring", "rustc-hash", "rustls", @@ -3487,7 +3501,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ "rand_chacha", - "rand_core", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", ] [[package]] @@ -3497,7 +3522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.9.5", ] [[package]] @@ -3509,13 +3534,19 @@ dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + [[package]] name = "rand_xorshift" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" dependencies = [ - "rand_core", + "rand_core 0.9.5", ] [[package]] @@ -5056,7 +5087,7 @@ dependencies = [ "http 1.4.2", "httparse", "log", - "rand", + "rand 0.9.4", "sha1", "thiserror 2.0.18", "utf-8", diff --git a/Cargo.toml b/Cargo.toml index 91afea25a..5d86d21ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ opentelemetry_sdk = {version = "0.32", features = ["rt-tokio"]} opfs = "0.2.0" percent-encoding = "2.3.2" proptest = "1.11" -rand = "0.9.4" +rand = "0.10.1" rayon = "1.11.0" regex-lite = "0.1.9" reqwest = {version = "0.13"} diff --git a/crates/mq-lang/Cargo.toml b/crates/mq-lang/Cargo.toml index 7b7a666e2..80510b292 100644 --- a/crates/mq-lang/Cargo.toml +++ b/crates/mq-lang/Cargo.toml @@ -49,7 +49,7 @@ uuid = {workspace = true, features = ["v4", "v7"]} [target.'cfg(target_arch = "wasm32")'.dependencies] web-sys = { version = "0.3", features = ["console"] } uuid = {workspace = true, features = ["js"]} -getrandom = { version = "0.3", features = ["wasm_js"] } +getrandom = { version = "0.4", features = ["wasm_js"] } [features] ast-json = ["smallvec/serde", "smol_str/serde"] diff --git a/crates/mq-lang/src/eval.rs b/crates/mq-lang/src/eval.rs index c47f8bab6..b1c659a32 100644 --- a/crates/mq-lang/src/eval.rs +++ b/crates/mq-lang/src/eval.rs @@ -1895,6 +1895,30 @@ fn resolve(ident: &str, env: &Shared>) -> Result MacroEvaluator for Evaluator { + fn eval_macro_body(&mut self, body: &Shared, _token_id: TokenId) -> Result { + let value = self.eval_macro(body); + + // If the result is already an AST (from quote), return it as-is + // If the result is None (e.g., from if(false) without else), return None to indicate removal + // Otherwise, wrap the body itself as an AST (for macros without quote) + match value { + Ok(RuntimeValue::Ast(ast)) => Ok(RuntimeValue::Ast(ast)), + Ok(RuntimeValue::None) => { + // Return None instead of empty block - this will cause the macro to be skipped + Ok(RuntimeValue::None) + } + Ok(_) | Err(_) => { + // Return the body as AST, not the evaluated result + // This allows macros without quote to work + Ok(RuntimeValue::Ast(Shared::clone(body))) + } + } + } +} + #[cfg(test)] mod tests { use std::f64::consts::PI; @@ -7745,30 +7769,6 @@ mod tests { } } -/// Implementation of MacroEvaluator trait for Evaluator. -/// This allows the macro expander to evaluate macro bodies during collection. -impl MacroEvaluator for Evaluator { - fn eval_macro_body(&mut self, body: &Shared, _token_id: TokenId) -> Result { - let value = self.eval_macro(body); - - // If the result is already an AST (from quote), return it as-is - // If the result is None (e.g., from if(false) without else), return None to indicate removal - // Otherwise, wrap the body itself as an AST (for macros without quote) - match value { - Ok(RuntimeValue::Ast(ast)) => Ok(RuntimeValue::Ast(ast)), - Ok(RuntimeValue::None) => { - // Return None instead of empty block - this will cause the macro to be skipped - Ok(RuntimeValue::None) - } - Ok(_) | Err(_) => { - // Return the body as AST, not the evaluated result - // This allows macros without quote to work - Ok(RuntimeValue::Ast(Shared::clone(body))) - } - } - } -} - #[cfg(test)] #[cfg(all(feature = "debugger", feature = "sync"))] mod debugger_tests { diff --git a/crates/mq-lang/src/eval/builtin/random.rs b/crates/mq-lang/src/eval/builtin/random.rs index 2a76331bf..991b25e9e 100644 --- a/crates/mq-lang/src/eval/builtin/random.rs +++ b/crates/mq-lang/src/eval/builtin/random.rs @@ -10,7 +10,7 @@ //! use a purpose-built secret-generation API for that. use crate::RuntimeValue; -use rand::Rng; +use rand::RngExt; use rand::seq::SliceRandom; /// Returns a pseudo-random `f64` uniformly distributed in `[0, 1)`.