plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


1cbdb08 — Peter John 2026-11-11T00:49:55+05:30
checker: read the working directory once per check, not per instantiation
compiler/checker/src/callsites.rs CHANGED
@@ -29,7 +29,10 @@ fn shownFile() -> String {
29
29
 
30
30
  /// `file` relative to the working directory when under it, as diagnostics show it.
31
31
  fn displayFile(file: &str) -> String {
32
+ let rel = withCheck(|s| {
33
+ let cwd = s.cwd.get_or_init(|| std::env::current_dir().ok());
32
- let rel = std::env::current_dir().ok().and_then(|d| std::path::Path::new(file).strip_prefix(d).ok().map(|p| p.display().to_string()));
34
+ cwd.as_ref().and_then(|d| std::path::Path::new(file).strip_prefix(d).ok().map(|p| p.display().to_string()))
35
+ });
33
36
  rel.unwrap_or_else(|| file.to_string())
34
37
  }
35
38
 
compiler/checker/src/state.rs CHANGED
@@ -105,6 +105,9 @@ pub(crate) struct CheckState {
105
105
  /// typed (`xs := []` then `xs.map(|x| x.length())`), by the receiver's node id: an error
106
106
  /// if nothing ever fixed that type (`checkSourceOnce`), as codegen would see `Unit`.
107
107
  pub(crate) open_receivers: RefCell<Vec<(ast::NodeId, crate::types::CheckError)>>,
108
+ /// The working directory, read once per check (`callsites::displayFile` needs it for
109
+ /// every instantiation; asking the OS each time was a measurable part of a check).
110
+ pub(crate) cwd: std::cell::OnceCell<Option<std::path::PathBuf>>,
108
111
  }
109
112
 
110
113
  thread_local! {