AotPrep collections_hot matmul tuning and bench tweaks
This commit is contained in:
@ -385,6 +385,16 @@ impl MirBuilder {
|
||||
} else {
|
||||
// Enhance diagnostics using Using simple registry (Phase 1)
|
||||
let mut msg = format!("Undefined variable: {}", name);
|
||||
|
||||
// Stage-3 keyword diagnostic (local/flow/try/catch/throw)
|
||||
if name == "local" && !crate::config::env::parser_stage3() {
|
||||
msg.push_str("\nHint: 'local' is a Stage-3 keyword. Enable NYASH_PARSER_STAGE3=1 (and HAKO_PARSER_STAGE3=1 for Stage-B).");
|
||||
msg.push_str("\nFor AotPrep verification, use tools/hakorune_emit_mir.sh which sets these automatically.");
|
||||
} else if (name == "flow" || name == "try" || name == "catch" || name == "throw")
|
||||
&& !crate::config::env::parser_stage3() {
|
||||
msg.push_str(&format!("\nHint: '{}' is a Stage-3 keyword. Enable NYASH_PARSER_STAGE3=1 (and HAKO_PARSER_STAGE3=1 for Stage-B).", name));
|
||||
}
|
||||
|
||||
let suggest = crate::using::simple_registry::suggest_using_for_symbol(&name);
|
||||
if !suggest.is_empty() {
|
||||
msg.push_str("\nHint: symbol appears in using module(s): ");
|
||||
|
||||
25
src/runner/modes/common_util/resolve/context.rs
Normal file
25
src/runner/modes/common_util/resolve/context.rs
Normal file
@ -0,0 +1,25 @@
|
||||
//! Resolve context — capture per-thread prelude merge context for enriched diagnostics.
|
||||
use std::cell::RefCell;
|
||||
|
||||
thread_local! {
|
||||
static LAST_MERGED_PRELUDES: RefCell<Vec<String>> = RefCell::new(Vec::new());
|
||||
}
|
||||
|
||||
/// Record the list of prelude file paths used for the last text merge in this thread.
|
||||
pub fn set_last_merged_preludes(paths: Vec<String>) {
|
||||
LAST_MERGED_PRELUDES.with(|c| {
|
||||
*c.borrow_mut() = paths;
|
||||
});
|
||||
}
|
||||
|
||||
/// Get a clone of the last recorded prelude file paths (if any).
|
||||
pub fn clone_last_merged_preludes() -> Vec<String> {
|
||||
LAST_MERGED_PRELUDES.with(|c| c.borrow().clone())
|
||||
}
|
||||
|
||||
/// Take and clear the last recorded prelude file paths.
|
||||
#[allow(dead_code)]
|
||||
pub fn take_last_merged_preludes() -> Vec<String> {
|
||||
LAST_MERGED_PRELUDES.with(|c| std::mem::take(&mut *c.borrow_mut()))
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ pub mod using_resolution;
|
||||
pub mod prelude_manager;
|
||||
pub mod selfhost_pipeline;
|
||||
pub mod path_util;
|
||||
pub mod context;
|
||||
|
||||
// 📦 箱化モジュールの公開にゃ!
|
||||
pub use using_resolution::{
|
||||
@ -54,3 +55,9 @@ pub use strip::{
|
||||
merge_prelude_asts_with_main,
|
||||
merge_prelude_text,
|
||||
};
|
||||
|
||||
// Expose context helpers for enhanced diagnostics
|
||||
pub use context::{
|
||||
set_last_merged_preludes,
|
||||
clone_last_merged_preludes,
|
||||
};
|
||||
|
||||
@ -777,6 +777,8 @@ pub fn merge_prelude_text(
|
||||
dfs_text(runner, p, &mut expanded, &mut seen)?;
|
||||
}
|
||||
let prelude_paths = &expanded;
|
||||
// Record for enriched diagnostics (parse error context)
|
||||
crate::runner::modes::common_util::resolve::set_last_merged_preludes(prelude_paths.clone());
|
||||
|
||||
if prelude_paths.is_empty() {
|
||||
// No using statements, return original
|
||||
|
||||
@ -66,6 +66,18 @@ impl NyashRunner {
|
||||
Ok(ast) => ast,
|
||||
Err(e) => {
|
||||
eprintln!("❌ Parse error in {}: {}", filename, e);
|
||||
// Enhanced context: list merged prelude files if any (from text-merge path)
|
||||
let preludes = crate::runner::modes::common_util::resolve::clone_last_merged_preludes();
|
||||
if !preludes.is_empty() {
|
||||
eprintln!("[parse/context] merged prelude files ({}):", preludes.len());
|
||||
let show = std::cmp::min(16, preludes.len());
|
||||
for p in preludes.iter().take(show) {
|
||||
eprintln!(" - {}", p);
|
||||
}
|
||||
if preludes.len() > show {
|
||||
eprintln!(" ... ({} more)", preludes.len() - show);
|
||||
}
|
||||
}
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
@ -183,6 +183,18 @@ impl NyashRunner {
|
||||
Ok(ast) => ast,
|
||||
Err(e) => {
|
||||
eprintln!("❌ Parse error in {}: {}", filename, e);
|
||||
// Enhanced context: list merged prelude files if any
|
||||
let preludes = crate::runner::modes::common_util::resolve::clone_last_merged_preludes();
|
||||
if !preludes.is_empty() {
|
||||
eprintln!("[parse/context] merged prelude files ({}):", preludes.len());
|
||||
let show = std::cmp::min(16, preludes.len());
|
||||
for p in preludes.iter().take(show) {
|
||||
eprintln!(" - {}", p);
|
||||
}
|
||||
if preludes.len() > show {
|
||||
eprintln!(" ... ({} more)", preludes.len() - show);
|
||||
}
|
||||
}
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user