feat: Add parallel HTTP server E2E tests and enhance plugin system
- Add e2e_plugin_net_additional.rs with parallel server tests - Fix test to properly handle request objects (no double accept) - Add comprehensive net-plugin documentation - Implement debug tracing for method calls - Enhance plugin lifecycle documentation - Improve error handling in plugin loader - Add leak tracking infrastructure (for future use) - Update language spec with latest plugin features This enhances test coverage for concurrent HTTP servers and improves the overall plugin system documentation and debugging capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -228,6 +228,9 @@ pub struct NyashInterpreter {
|
||||
/// 共有ランタイム(Boxレジストリ等)
|
||||
#[allow(dead_code)]
|
||||
pub(super) runtime: NyashRuntime,
|
||||
|
||||
/// 現在の文脈で式結果が破棄されるか(must_use警告用)
|
||||
pub(super) discard_context: bool,
|
||||
}
|
||||
|
||||
impl NyashInterpreter {
|
||||
@ -259,6 +262,7 @@ impl NyashInterpreter {
|
||||
invalidated_ids: Arc::new(Mutex::new(HashSet::new())),
|
||||
stdlib: None, // 遅延初期化
|
||||
runtime,
|
||||
discard_context: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,6 +296,7 @@ impl NyashInterpreter {
|
||||
invalidated_ids: Arc::new(Mutex::new(HashSet::new())),
|
||||
stdlib: None,
|
||||
runtime,
|
||||
discard_context: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,6 +326,7 @@ impl NyashInterpreter {
|
||||
invalidated_ids: Arc::new(Mutex::new(HashSet::new())),
|
||||
stdlib: None, // 遅延初期化
|
||||
runtime,
|
||||
discard_context: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,6 +357,7 @@ impl NyashInterpreter {
|
||||
invalidated_ids: Arc::new(Mutex::new(HashSet::new())),
|
||||
stdlib: None,
|
||||
runtime,
|
||||
discard_context: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,8 +386,12 @@ impl NyashInterpreter {
|
||||
ASTNode::Program { statements, .. } => {
|
||||
let mut result: Box<dyn NyashBox> = Box::new(VoidBox::new());
|
||||
|
||||
for statement in statements.iter() {
|
||||
let last = statements.len().saturating_sub(1);
|
||||
for (i, statement) in statements.iter().enumerate() {
|
||||
let prev = self.discard_context;
|
||||
self.discard_context = i != last; // 最終文以外は値が破棄される
|
||||
result = self.execute_statement(statement)?;
|
||||
self.discard_context = prev;
|
||||
|
||||
// 制御フローチェック
|
||||
match &self.control_flow {
|
||||
|
||||
@ -996,6 +996,10 @@ impl NyashInterpreter {
|
||||
method: &str,
|
||||
arguments: &[ASTNode],
|
||||
) -> Result<Box<dyn NyashBox>, RuntimeError> {
|
||||
// Guard: use-after-fini is a runtime error (明示ライフサイクル)
|
||||
if plugin_box.is_finalized() {
|
||||
return Err(RuntimeError::RuntimeFailure { message: format!("Use after fini: {}", plugin_box.box_type) });
|
||||
}
|
||||
eprintln!("🔍 execute_plugin_box_v2_method called: {}.{}", plugin_box.box_type, method);
|
||||
let mut arg_values: Vec<Box<dyn NyashBox>> = Vec::new();
|
||||
for arg in arguments {
|
||||
|
||||
@ -20,6 +20,26 @@ macro_rules! debug_trace {
|
||||
}
|
||||
|
||||
impl NyashInterpreter {
|
||||
fn warn_if_must_use(&self, value: &Box<dyn NyashBox>) {
|
||||
if std::env::var("NYASH_LINT_MUSTUSE").unwrap_or_default() != "1" { return; }
|
||||
if !self.discard_context { return; }
|
||||
// 重資源のヒューリスティクス: プラグインBox、またはHTTP/Socket/File系の型名
|
||||
#[cfg(all(feature = "plugins", not(target_arch = "wasm32")))]
|
||||
{
|
||||
if value.as_any().downcast_ref::<crate::runtime::plugin_loader_v2::PluginBoxV2>().is_some() {
|
||||
eprintln!("[lint:must_use] Discarded resource value (plugin box). Consider assigning it or calling fini().");
|
||||
return;
|
||||
}
|
||||
}
|
||||
let ty = value.type_name();
|
||||
let heavy = matches!(ty,
|
||||
"FileBox" | "SocketBox" | "SocketServerBox" | "SocketClientBox" | "SocketConnBox" |
|
||||
"HTTPServerBox" | "HTTPRequestBox" | "HTTPResponseBox" | "HttpClientBox"
|
||||
);
|
||||
if heavy {
|
||||
eprintln!("[lint:must_use] Discarded {} value. Consider assigning it or calling fini().", ty);
|
||||
}
|
||||
}
|
||||
/// 文を実行 - Core statement execution engine
|
||||
pub(super) fn execute_statement(&mut self, statement: &ASTNode) -> Result<Box<dyn NyashBox>, RuntimeError> {
|
||||
match statement {
|
||||
@ -180,8 +200,12 @@ impl NyashInterpreter {
|
||||
Ok(Box::new(VoidBox::new()))
|
||||
}
|
||||
|
||||
// 式文
|
||||
_ => self.execute_expression(statement),
|
||||
// 式文(結果は多くの場合破棄されるため、must_use警告を出力)
|
||||
_ => {
|
||||
let v = self.execute_expression(statement)?;
|
||||
self.warn_if_must_use(&v);
|
||||
Ok(v)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user