rune-rs / rune

An embeddable dynamic programming language for Rust.
https://rune-rs.github.io
Apache License 2.0
1.7k stars 85 forks source link

`println!` macro has confusing error message when the first argument isn't a string literal #730

Open Nathan-Fenner opened 1 month ago

Nathan-Fenner commented 1 month ago

Playground link

pub fn main() {
    let x = 5;
    println!(x + 7);
}

(note, this syntax is incorrect - it should be println!("{}", x+7);)

However, the error message is highly misleading:

Failed to build rune sources (see diagnostics for details)

error: No local variable `x`
  ┌─ entry:3:11
  │
3 │     println!(x + 7);
  │              ^ No local variable `x`