freeze: macro platform complete; default ON with profiles; env consolidation; docs + smokes\n\n- Profiles: --profile {lite|dev|ci|strict} (dev-like default for macros)\n- Macro paths: prefer NYASH_MACRO_PATHS (legacy envs deprecated with warnings)\n- Selfhost pre-expand: auto mode, PyVM-only, add smokes (array/map)\n- Docs: user-macros updated; new macro-profiles guide; AGENTS freeze note; CURRENT_TASK freeze\n- Compat: non-breaking; legacy envs print deprecation notices\n
This commit is contained in:
@ -13,6 +13,27 @@ use crate::tokenizer::TokenType;
|
||||
use std::collections::HashMap;
|
||||
|
||||
impl NyashParser {
|
||||
/// Forbid user-defined methods named exactly as the box (constructor-like names).
|
||||
/// Nyash constructors are explicit: init/pack/birth. A method with the same name
|
||||
/// as the box is likely a mistaken constructor attempt; reject for clarity.
|
||||
fn validate_no_ctor_like_name(
|
||||
&mut self,
|
||||
box_name: &str,
|
||||
methods: &HashMap<String, ASTNode>,
|
||||
) -> Result<(), ParseError> {
|
||||
if methods.contains_key(box_name) {
|
||||
let line = self.current_token().line;
|
||||
return Err(ParseError::UnexpectedToken {
|
||||
found: self.current_token().token_type.clone(),
|
||||
expected: format!(
|
||||
"method name must not match box name '{}'; use init/pack/birth for constructors",
|
||||
box_name
|
||||
),
|
||||
line,
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Validate that birth_once properties do not have cyclic dependencies via me.<prop> references
|
||||
fn validate_birth_once_cycles(
|
||||
&mut self,
|
||||
@ -592,6 +613,8 @@ impl NyashParser {
|
||||
}
|
||||
|
||||
self.consume(TokenType::RBRACE)?;
|
||||
// 🚫 Disallow method named same as the box (constructor-like confusion)
|
||||
self.validate_no_ctor_like_name(&name, &methods)?;
|
||||
|
||||
// 🔥 Override validation
|
||||
for parent in &extends {
|
||||
|
||||
Reference in New Issue
Block a user