diff --git a/lang/src/lib.rs b/lang/src/lib.rs index bf021a0..b959bb0 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -1034,6 +1034,7 @@ pub struct Types { tasks: Vec>, } +// TODO: remove this trait TypeParser { fn tys(&mut self) -> &mut Types; fn ty_display(&self, of: ty::Id) -> ty::Display; @@ -1043,6 +1044,7 @@ trait TypeParser { fn eval_global(&mut self, file: Module, name: Ident, expr: &Expr) -> ty::Id; fn infer_type(&mut self, expr: &Expr) -> ty::Id; fn error(&self, file: Module, pos: Pos, msg: impl Display) -> ty::Id; + fn warn(&self, file: Module, pos: Pos, msg: impl Display) -> ty::Id; fn find_type( &mut self, @@ -1118,7 +1120,7 @@ trait TypeParser { }; if let Err(proper_case) = self.tys().case(ty)(f.ident_str(name)) { - self.error( + self.warn( from_file, pos, format_args!( diff --git a/lang/src/son.rs b/lang/src/son.rs index 707d46b..87fa11c 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -4969,7 +4969,7 @@ impl<'a> Codegen<'a> { #[track_caller] fn warn(&self, pos: Pos, msg: impl core::fmt::Display) { - let mut buf = self.errors.borrow_mut(); + let mut buf = self.warnings.borrow_mut(); write!(buf, "(W) {}", self.file().report(pos, msg)).unwrap(); } @@ -5072,6 +5072,12 @@ impl TypeParser for Codegen<'_> { ty::Id::NEVER } + fn warn(&self, file: Module, pos: Pos, msg: impl Display) -> ty::Id { + let mut buf = self.warnings.borrow_mut(); + write!(buf, "(W) {}", self.files[file.index()].report(pos, msg)).unwrap(); + ty::Id::NEVER + } + fn find_local_ty(&mut self, ident: Ident) -> Option { self.ci.scope.vars.iter().rfind(|v| (v.id == ident && v.value() == NEVER)).map(|v| v.ty) }