diff --git a/cpclib-asm/src/assembler/mod.rs b/cpclib-asm/src/assembler/mod.rs index 5d9e48e0..baffa7e6 100644 --- a/cpclib-asm/src/assembler/mod.rs +++ b/cpclib-asm/src/assembler/mod.rs @@ -3355,12 +3355,8 @@ pub fn visit_located_token( let nb_additional_warnings = env.warnings.len() - nb_warnings; for i in 0..nb_additional_warnings { let warning = &mut env.warnings[i + nb_warnings]; - if !warning.is_located() { - *warning = AssemblerError::RelocatedWarning { - warning: Box::new(warning.clone()), - span: span.clone() - }; - } + *warning = warning.clone().locate_warning(span.clone()); + // TODO check why it has been done this way // maybe source code is not retrained and there are random crashes ? // anyway I comment it now because it breaks warning merge diff --git a/cpclib-asm/src/assembler/processed_token.rs b/cpclib-asm/src/assembler/processed_token.rs index 2cba38a6..2c7c7556 100644 --- a/cpclib-asm/src/assembler/processed_token.rs +++ b/cpclib-asm/src/assembler/processed_token.rs @@ -1009,7 +1009,7 @@ where msg: format!("Header has been removed for {txt}") }; let warning = if let Some(span) = possible_span { - warning.locate(span.clone()) + warning.locate_warning(span.clone()) } else { warning diff --git a/cpclib-asm/src/error.rs b/cpclib-asm/src/error.rs index 29ee2c1f..3e37f1ad 100644 --- a/cpclib-asm/src/error.rs +++ b/cpclib-asm/src/error.rs @@ -340,6 +340,18 @@ impl AssemblerError { } } } + + pub fn locate_warning(self, span: Z80Span) -> Self { + if self.is_located() { + self + } + else { + AssemblerError::RelocatedWarning { + span, + warning: Box::new(self) + } + } + } } pub(crate) const LD_WRONG_SOURCE: &'static str = "LD: error in the source"; diff --git a/cpclib-visual-bndbuild/src/lib.rs b/cpclib-visual-bndbuild/src/lib.rs index 39fa0185..1cdf546f 100644 --- a/cpclib-visual-bndbuild/src/lib.rs +++ b/cpclib-visual-bndbuild/src/lib.rs @@ -341,7 +341,10 @@ impl BndBuildApp { ui.menu_button("Open Recent", |ui| { for fname in self.recent_files.clone().iter().rev() { if ui - .add(Button::new(fname.display().to_string()).wrap_mode(egui::TextWrapMode::Extend)) + .add( + Button::new(fname.display().to_string()) + .wrap_mode(egui::TextWrapMode::Extend) + ) .clicked() { self.load(fname);