mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-13 19:06:16 +01:00
fix variable shadowing not working (how was this not noticed until now??)
This commit is contained in:
@@ -25,9 +25,15 @@ impl MersStatement for AssignTo {
|
||||
return Err("can't init to statement type AssignTo".to_string().into());
|
||||
}
|
||||
let source = self.source.check(info, None)?;
|
||||
let target = match self.target.check(info, Some(&source)) {
|
||||
let target = match self
|
||||
.target
|
||||
.check(info, if self.is_init { Some(&source) } else { None })
|
||||
{
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
if !self.is_init {
|
||||
return Err(e);
|
||||
}
|
||||
return Err(CheckError::new()
|
||||
.src(vec![
|
||||
(self.pos_in_src.clone(), None),
|
||||
@@ -35,7 +41,7 @@ impl MersStatement for AssignTo {
|
||||
(self.source.source_range(), Some(error_colors::InitFrom)),
|
||||
])
|
||||
.msg(format!("Cannot initialize:"))
|
||||
.err(e))
|
||||
.err(e));
|
||||
}
|
||||
};
|
||||
if !self.is_init {
|
||||
|
||||
@@ -44,12 +44,12 @@ pub trait MersStatement: Debug + Send + Sync {
|
||||
fn run_custom(&self, info: &mut Info) -> Data;
|
||||
/// if true, local variables etc. will be contained inside their own scope.
|
||||
fn has_scope(&self) -> bool;
|
||||
fn check(&self, info: &mut CheckInfo, assign: Option<&Type>) -> Result<Type, CheckError> {
|
||||
fn check(&self, info: &mut CheckInfo, init_to: Option<&Type>) -> Result<Type, CheckError> {
|
||||
info.global.depth += 1;
|
||||
if self.has_scope() {
|
||||
info.create_scope();
|
||||
}
|
||||
let o = self.check_custom(info, assign);
|
||||
let o = self.check_custom(info, init_to);
|
||||
if info.global.enable_hooks {
|
||||
// Hooks - keep in sync with run/mod.rs/compile() hooks section
|
||||
'hook_save_info_at: {
|
||||
|
||||
Reference in New Issue
Block a user