From e1a7b5e1422e5a1c35e0db28e12fc9e7d8b9c319 Mon Sep 17 00:00:00 2001 From: Patrick Laflamme Date: Tue, 28 May 2024 08:13:14 -0400 Subject: [PATCH] Remove all optional positions from the checker events (#144) --- checker/definitions/internal.ts.d.bin | Bin 22247 -> 22053 bytes checker/src/context/environment.rs | 32 ++++++++------- checker/src/context/information.rs | 8 ++-- checker/src/diagnostics.rs | 43 ++++++++++----------- checker/src/events/application.rs | 32 ++++++++------- checker/src/events/mod.rs | 10 ++--- checker/src/features/constant_functions.rs | 3 ++ checker/src/features/functions.rs | 10 ++++- checker/src/features/iteration.rs | 28 +++++++++----- checker/src/features/modules.rs | 2 +- checker/src/features/objects.rs | 5 ++- checker/src/features/template_literal.rs | 13 +++---- checker/src/lib.rs | 2 +- checker/src/synthesis/classes.rs | 15 +++---- checker/src/synthesis/expressions.rs | 36 +++++++++-------- checker/src/synthesis/extensions/jsx.rs | 15 ++++--- checker/src/synthesis/interfaces.rs | 17 ++++++-- checker/src/synthesis/statements.rs | 12 ++++-- checker/src/synthesis/type_annotations.rs | 7 ++-- checker/src/types/calling.rs | 22 +++++++---- checker/src/types/classes.rs | 7 +++- checker/src/types/functions.rs | 13 ++++++- checker/src/types/others.rs | 39 +++++++++++-------- checker/src/types/properties.rs | 12 ++---- src/reporting.rs | 10 ++--- 25 files changed, 231 insertions(+), 162 deletions(-) diff --git a/checker/definitions/internal.ts.d.bin b/checker/definitions/internal.ts.d.bin index ad334ba64269a8e6cc9ac69b63b088479071db3a..397a5a86cb1822dff2a0bca314fb39ec39b952e4 100644 GIT binary patch literal 22053 zcmdU13z$^Jl|I$Cd!}bV1$@LOTnEHP1`ywjfGA+Zh_En33?laQ+<}&!?yC^HE~zn|F6frw`Y0)O<;E$ z&fKa~r>ah!sygS?ZR16TOLBI$x=iGxy+tMiq^Y;q8Fb}~ zK_?>a*PJUAtHG-3l02{vjTZSfK$v^cb0O!Y>>!` zks|8=lIjYoIgFGO5t&TH5Yv42MzxHlf%s>r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Bzn;51yGM2Xzc7z z376R``PF`Rskl5Sgd>D98NSws%&@JE~(NXC^Ynd*|e0uF%YXLCI|&pMFOGeueDD3WO%3 z;qTivW4{^u&)nyL{rBDfpqU5G+}G~==Y&5FXl^pYvYwfBvQz!N+YMWD7VuIG8G#$Nmn|l1$rGJAv297k{=3q$w5_k*@X}ZnEQ20Cgv2qq>*laA~H}zv>4y2oA)#P^r z#=r#0HiukrqBI6>K(#rT(T?0Pu%qdkV<%m1eTq)GLQS)Y^e=xxKNe0wwmI~R{bIxz zIpW~n4EmT%;TqBynF8f7rZ#R!jWo$v-(r3OV^}$xL{aJQ1&pO>{I0;}m^}PS!x;D> z*{JMP8}vL!)LtqW#vQ)3x3#5Sy;tJzRzfq}dV6?OfK$UkV=U`0iZttcdoc?TG@;#( zeR$|5kMbE~5nmi}d65OZ8E#&x`PJvE?vqfCA%2)dA0guK+MOahn%Y|!`?)Gtfa5IU z3dfa>Zy#S)Iu zH2a`{PuDLNYB~3q-5jAIG>m0%7;CX@05gR68g0;y#s9rl6brl)vGiZj5_oP)xI|K` zL%PhgY~@yAX?Q%nY5Ilj!FI&7>tE6^dYb3k#zhm{tT$!~)*NX_sxc8_1C4hld>$a! zMWfbuGedHXKfS}(?V5q@y1tyigM1cHJ!?4rP_OP&5NOhBikgEIS>j_<4^#AxUUpaJ zuu{8KJ-m&>&)~t#>T@eDx;FeajolHtkJH#Kp_7rF7i)avj^}FiT?RUbGz*b`$bBZx z6{5dkZ-Pwg}T~27|}HS8OCOIx~l-oopU-lM-@F!6B_4a^EnLrNIs^! z;6BnI`19xEvzAbuD7ieRJL=N+Rq7cJL^*1R0>Eg89 z^~WhkTnHOmgY?%Q|Czk+aw+ZIxrl$mlZ-U$YdvdDe=l8Q%cz}w;{zoAb Environment<'a> { &with, rhs, &mut checking_data.types, - Some(span), + span, &checking_data.options, )? .unwrap_or(rhs)), @@ -781,7 +781,12 @@ impl<'a> Environment<'a> { } /// TODO decidable & private? - pub fn delete_property(&mut self, on: TypeId, property: &PropertyKey) -> bool { + pub fn delete_property( + &mut self, + on: TypeId, + property: &PropertyKey, + position: SpanWithSource, + ) -> bool { let existing = self.property_in(on, property); let under = property.into_owned(); @@ -801,7 +806,7 @@ impl<'a> Environment<'a> { new: PropertyValue::Deleted, initialization: false, publicity: Publicity::Public, - position: None, + position, }); existing @@ -1163,6 +1168,7 @@ impl<'a> Environment<'a> { let combined_result = R::combine(condition, truthy_result, falsy_result, &mut checking_data.types); + let position = pos.with_source(self.get_source()); match self.context_type.parent { GeneralContext::Syntax(syn) => { merge_info( @@ -1172,6 +1178,7 @@ impl<'a> Environment<'a> { truthy_info, falsy_info, &mut checking_data.types, + position, ); } GeneralContext::Root(root) => { @@ -1182,6 +1189,7 @@ impl<'a> Environment<'a> { truthy_info, falsy_info, &mut checking_data.types, + position, ); } } @@ -1253,7 +1261,7 @@ impl<'a> Environment<'a> { &checking_data.types, checking_data.options.debug_types, ), - annotation_position: Some(position.with_source(self.get_source())), + annotation_position: position.with_source(self.get_source()), returned_position, }, ); @@ -1273,11 +1281,8 @@ impl<'a> Environment<'a> { ) -> Result<(), NotInLoopOrCouldNotFindLabel> { if let Some(carry) = self.find_label_or_conditional_count(label, true) { self.info.events.push( - FinalEvent::Continue { - position: Some(position.with_source(self.get_source())), - carry, - } - .into(), + FinalEvent::Continue { position: position.with_source(self.get_source()), carry } + .into(), ); Ok(()) } else { @@ -1295,11 +1300,8 @@ impl<'a> Environment<'a> { ) -> Result<(), NotInLoopOrCouldNotFindLabel> { if let Some(carry) = self.find_label_or_conditional_count(label, false) { self.info.events.push( - FinalEvent::Break { - position: Some(position.with_source(self.get_source())), - carry, - } - .into(), + FinalEvent::Break { position: position.with_source(self.get_source()), carry } + .into(), ); Ok(()) } else { @@ -1321,7 +1323,7 @@ impl<'a> Environment<'a> { under: &PropertyKey, new: TypeId, types: &mut TypeStore, - setter_position: Option, + setter_position: SpanWithSource, options: &TypeCheckOptions, ) -> Result, SetPropertyError> { crate::types::properties::set_property( diff --git a/checker/src/context/information.rs b/checker/src/context/information.rs index 8a71d50a..42711870 100644 --- a/checker/src/context/information.rs +++ b/checker/src/context/information.rs @@ -59,7 +59,7 @@ impl LocalInformation { under: PropertyKey<'static>, to: PropertyValue, register_setter_event: bool, - position: Option, + position: SpanWithSource, ) { // crate::utilities::notify!("Registering {:?} {:?} {:?}", on, under, to); self.current_properties.entry(on).or_default().push((publicity, under.clone(), to.clone())); @@ -89,6 +89,7 @@ impl LocalInformation { &mut self, prototype: Option, types: &mut crate::types::TypeStore, + position: SpanWithSource, // TODO if this on environment instead it could be worked out? is_under_dyn: bool, is_function_this: bool, @@ -111,7 +112,7 @@ impl LocalInformation { let value = Event::CreateObject { referenced_in_scope_as: ty, prototype, - position: None, + position, is_function_this, }; self.events.push(value); @@ -317,6 +318,7 @@ pub fn merge_info( truthy: LocalInformation, mut falsy: Option, types: &mut TypeStore, + position: SpanWithSource, ) { onto.events.push(Event::Conditionally { condition, @@ -325,7 +327,7 @@ pub fn merge_info( .as_mut() .map(|falsy| mem::take(&mut falsy.events).into_boxed_slice()) .unwrap_or_default(), - position: None, + position, }); // TODO don't need to do above some scope diff --git a/checker/src/diagnostics.rs b/checker/src/diagnostics.rs index 6c712e09..18388919 100644 --- a/checker/src/diagnostics.rs +++ b/checker/src/diagnostics.rs @@ -41,7 +41,7 @@ pub enum Diagnostic { PositionWithAdditionalLabels { reason: String, position: SpanWithSource, - labels: Vec<(String, Option)>, + labels: Vec<(String, SpanWithSource)>, kind: DiagnosticKind, }, } @@ -64,9 +64,7 @@ impl Diagnostic { Diagnostic::Global { .. } => Left(Left(iter::empty())), Diagnostic::Position { position: span, .. } => Left(Right(iter::once(span.source))), Diagnostic::PositionWithAdditionalLabels { position: pos, labels, .. } => { - Right(iter::once(pos.source).chain( - labels.iter().filter_map(|(_, span)| span.as_ref().map(|span| span.source)), - )) + Right(iter::once(pos.source).chain(labels.iter().map(|(_, span)| span.source))) } } } @@ -311,7 +309,7 @@ mod defined_errors_and_warnings { expected_return_type: TypeStringRepresentation, returned_type: TypeStringRepresentation, /// Can be `None` if it is inferred parameters - annotation_position: Option, + annotation_position: SpanWithSource, returned_position: SpanWithSource, }, // TODO are these the same errors? @@ -387,7 +385,8 @@ mod defined_errors_and_warnings { DoubleDefaultExport(SpanWithSource), CannotOpenFile { file: CouldNotOpenFile, - position: Option, + /// `None` if reading it from entry point (aka CLI args) + import_position: Option, }, VariableNotDefinedInContext { variable: &'a str, @@ -477,7 +476,7 @@ mod defined_errors_and_warnings { format!( "{parameter_type} was specialised with type {restriction}" ), - Some(restriction_pos), + restriction_pos, )], kind, } @@ -489,7 +488,7 @@ mod defined_errors_and_warnings { position: argument_position, labels: vec![( format!("Parameter has type {parameter_type}"), - Some(parameter_position), + parameter_position, )], kind, } @@ -502,7 +501,7 @@ mod defined_errors_and_warnings { kind, labels: vec![( "(non-optional) Parameter declared here".into(), - Some(parameter_position), + parameter_position, )], } } @@ -542,22 +541,22 @@ mod defined_errors_and_warnings { FunctionCallingError::NeedsToBeCalledWithNewKeyword(position) => Diagnostic::Position { reason: "class constructor must be called with new".to_owned(), kind, position }, FunctionCallingError::TDZ { error: TDZ { position, variable_name }, call_site } => Diagnostic::PositionWithAdditionalLabels { reason: format!("Variable '{variable_name}' used before declaration"), - position: call_site.unwrap(), + position: call_site, kind, labels: vec![( "Variable referenced here".to_owned(), - Some(position), + position, )], }, FunctionCallingError::SetPropertyConstraint { property_type, value_type, assignment_position, call_site } => Diagnostic::PositionWithAdditionalLabels { reason: "Invalid assignment to parameter".to_owned(), - position: call_site.unwrap(), + position: call_site, kind, labels: vec![( format!( "Type {value_type} does not meet property constraint {property_type}" ), - Some(assignment_position), + assignment_position, )], }, FunctionCallingError::UnconditionalThrow { value, call_site } => { @@ -565,7 +564,7 @@ mod defined_errors_and_warnings { reason: format!( "{value} unconditionally thrown in function" ), - position: call_site.unwrap(), + position: call_site, kind, } } @@ -590,7 +589,7 @@ mod defined_errors_and_warnings { position: value_site, labels: vec![( format!("Variable declared with type {variable_type}"), - Some(variable_site), + variable_site, )], kind, }, @@ -647,10 +646,10 @@ mod defined_errors_and_warnings { reason: format!( "Cannot return {returned_type} because the function is expected to return {expected_return_type}", ), - labels: annotation_position.into_iter().map(|annotation_position| ( + labels: vec![( format!("Function annotated to return {expected_return_type} here"), - Some(annotation_position), - )).collect(), + annotation_position, + )], position: returned_position, kind, }, @@ -779,10 +778,10 @@ mod defined_errors_and_warnings { kind, }, TypeCheckError::DoubleDefaultExport(_) => todo!(), - TypeCheckError::CannotOpenFile { file, position } => if let Some(position) = position { + TypeCheckError::CannotOpenFile { file, import_position } => if let Some(import_position) = import_position { Diagnostic::Position { reason: "Cannot find file".to_owned(), - position, + position: import_position, kind, } } else { @@ -845,7 +844,7 @@ mod defined_errors_and_warnings { ), labels: vec![( format!("Function has base type {parameter} here"), - Some(parameter_position), + parameter_position, )], position: overloaded_parameter_position, kind, @@ -856,7 +855,7 @@ mod defined_errors_and_warnings { ), labels: vec![( format!("Function annotated to return {base} here"), - Some(base_position), + base_position, )], position: overload_position, kind, diff --git a/checker/src/events/application.rs b/checker/src/events/application.rs index 8e5035eb..6a9c9313 100644 --- a/checker/src/events/application.rs +++ b/checker/src/events/application.rs @@ -1,3 +1,5 @@ +use source_map::SpanWithSource; + use super::{CallingTiming, Event, FinalEvent, PrototypeArgument, RootReference}; use crate::{ @@ -42,6 +44,7 @@ pub(crate) fn apply_event( target: &mut InvocationContext, types: &mut TypeStore, errors: &mut ErrorsAndInfo, + call_site: SpanWithSource, ) -> ApplicationResult { match event { Event::ReadsReference { reference, reflects_dependency, position } => { @@ -57,7 +60,7 @@ pub(crate) fn apply_event( variable_name: environment.get_variable_name(id).to_owned(), position, }, - call_site: None, + call_site, }); TypeId::ERROR_TYPE } @@ -138,7 +141,7 @@ pub(crate) fn apply_event( PropertyValue::Setter(_) => todo!(), // TODO this might be a different thing at some point PropertyValue::Deleted => { - environment.delete_property(on, &under); + environment.delete_property(on, &under, position); return None.into(); } PropertyValue::Dependent { .. } => { @@ -203,8 +206,8 @@ pub(crate) fn apply_event( crate::types::calling::FunctionCallingError::SetPropertyConstraint { property_type: property_constraint, value_type, - assignment_position: position.unwrap(), - call_site: None, + assignment_position: position, + call_site, }, ); } else { @@ -322,6 +325,7 @@ pub(crate) fn apply_event( target, types, errors, + position, ); if result.is_it_so_over() { @@ -351,6 +355,7 @@ pub(crate) fn apply_event( target, types, errors, + position, ); if result.is_it_so_over() { @@ -372,6 +377,7 @@ pub(crate) fn apply_event( target, types, errors, + position, ); if result.is_it_so_over() { @@ -409,6 +415,7 @@ pub(crate) fn apply_event( target, types, errors, + position, ); // TODO temp @@ -500,10 +507,9 @@ pub(crate) fn apply_event( types, false, ); - errors.errors.push(FunctionCallingError::UnconditionalThrow { - value, - call_site: None, - }); + errors + .errors + .push(FunctionCallingError::UnconditionalThrow { value, call_site }); } FinalEvent::Throw { thrown: substituted_thrown, position } } @@ -515,12 +521,7 @@ pub(crate) fn apply_event( }); } // TODO Needs a position (or not?) - Event::CreateObject { - referenced_in_scope_as, - prototype, - position: _, - is_function_this, - } => { + Event::CreateObject { referenced_in_scope_as, prototype, position, is_function_this } => { // TODO let is_under_dyn = true; @@ -530,6 +531,7 @@ pub(crate) fn apply_event( target.get_latest_info(environment).new_object( Some(prototype), types, + position, is_under_dyn, is_function_this, ) @@ -537,6 +539,7 @@ pub(crate) fn apply_event( PrototypeArgument::None => target.get_latest_info(environment).new_object( None, types, + position, is_under_dyn, is_function_this, ), @@ -587,6 +590,7 @@ pub(crate) fn apply_event( target, errors, types, + call_site, ); } } diff --git a/checker/src/events/mod.rs b/checker/src/events/mod.rs index 012e8d3f..69cc7538 100644 --- a/checker/src/events/mod.rs +++ b/checker/src/events/mod.rs @@ -74,7 +74,7 @@ pub enum Event { /// see initialization: bool, publicity: Publicity, - position: Option, + position: SpanWithSource, }, /// This includes closed over variables, anything dependent CallsType { @@ -90,7 +90,7 @@ pub enum Event { condition: TypeId, true_events: Box<[Event]>, else_events: Box<[Event]>, - position: Option, + position: SpanWithSource, }, /// Run events multiple times Iterate { @@ -123,7 +123,7 @@ pub enum Event { /// /// This is also for the specialisation (somehow) referenced_in_scope_as: TypeId, - position: Option, + position: SpanWithSource, /// Debug only is_function_this: bool, }, @@ -150,12 +150,12 @@ pub enum FinalEvent { }, Break { carry: u8, - position: Option, + position: SpanWithSource, }, /// TODO explain why this can't be done with just (or at least label makes it more difficult) Continue { carry: u8, - position: Option, + position: SpanWithSource, }, } diff --git a/checker/src/features/constant_functions.rs b/checker/src/features/constant_functions.rs index 35109aec..c07f8ed4 100644 --- a/checker/src/features/constant_functions.rs +++ b/checker/src/features/constant_functions.rs @@ -1,4 +1,5 @@ use iterator_endiate::EndiateIteratorExt; +use source_map::SpanWithSource; use crate::{ context::{get_on_ctx, information::InformationChain}, @@ -44,6 +45,7 @@ pub(crate) fn call_constant_function( types: &mut TypeStore, // TODO mut for satisfies which needs checking environment: &mut Environment, + _call_site: SpanWithSource, ) -> Result { // crate::utilities::notify!("Calling constant function {} with {:?}", name, arguments); // TODO as parameter @@ -353,6 +355,7 @@ pub(crate) fn call_constant_function( // value.first().ok_or(ConstantFunctionError::BadCall)?.0, // environment, // types, + // call_site, // ); // Ok(ConstantOutput::Value(value)) // } else { diff --git a/checker/src/features/functions.rs b/checker/src/features/functions.rs index 8eb3c0cf..6b29246f 100644 --- a/checker/src/features/functions.rs +++ b/checker/src/features/functions.rs @@ -206,6 +206,7 @@ pub fn synthesise_function_default_value<'a, T: crate::ReadFromFS, A: ASTImpleme &checking_data.types, ); + let at = A::expression_position(expression).with_source(environment.get_source()); if let SubTypeResult::IsNotSubType(_) = result { let expected = TypeStringRepresentation::from_type_id( parameter_ty, @@ -216,7 +217,6 @@ pub fn synthesise_function_default_value<'a, T: crate::ReadFromFS, A: ASTImpleme let found = TypeStringRepresentation::from_type_id(value, environment, &checking_data.types, false); - let at = A::expression_position(expression).with_source(environment.get_source()); checking_data.diagnostics_container.add_error(TypeCheckError::InvalidDefaultParameter { at, @@ -255,6 +255,7 @@ pub fn synthesise_function_default_value<'a, T: crate::ReadFromFS, A: ASTImpleme out.unwrap().0, None, &mut checking_data.types, + at, ); result @@ -668,6 +669,7 @@ where let this_constraint = function.this_constraint(&mut function_environment, checking_data).or(this_shape); + let position = function.get_position().with_source(base_environment.get_source()); // `this` changes stuff if let Scope::Function(ref mut scope) = function_environment.context_type.scope { match scope { @@ -710,6 +712,7 @@ where let this_constructed_object = function_environment.info.new_object( Some(prototype), &mut checking_data.types, + position, true, true, ); @@ -727,6 +730,7 @@ where let this_constructed_object = function_environment.info.new_object( None, &mut checking_data.types, + position, true, true, ); @@ -760,15 +764,19 @@ where &mut checking_data.types, &mut function_environment.info, prototype, + position, ); *this_object_type = new_this_object_type; + let position = + function.get_position().with_source(function_environment.get_source()); // TODO super/derived behavior types::classes::register_properties_into_environment( &mut function_environment, new_this_object_type, checking_data, properties, + position, ); function_environment.can_reference_this = diff --git a/checker/src/features/iteration.rs b/checker/src/features/iteration.rs index b2e91866..758d6e06 100644 --- a/checker/src/features/iteration.rs +++ b/checker/src/features/iteration.rs @@ -1,5 +1,7 @@ use std::{collections::HashMap, iter}; +use source_map::SpanWithSource; + use crate::{ context::{ environment::Label, get_value_of_variable, information::get_properties_on_type, @@ -43,6 +45,7 @@ pub fn synthesise_iteration( environment: &mut Environment, checking_data: &mut CheckingData, loop_body: impl FnOnce(&mut Environment, &mut CheckingData), + position: SpanWithSource, ) { match behavior { IterationBehavior::While(condition) => { @@ -61,10 +64,8 @@ pub fn synthesise_iteration( let break_event = Event::Conditionally { condition, true_events: Default::default(), - else_events: Box::new([ - FinalEvent::Break { position: None, carry: 0 }.into() - ]), - position: None, + else_events: Box::new([FinalEvent::Break { position, carry: 0 }.into()]), + position, }; environment.info.events.push(break_event); @@ -105,6 +106,7 @@ pub fn synthesise_iteration( &mut InvocationContext::new_empty(), &mut errors_and_info, &mut checking_data.types, + position, ); if let ApplicationResult::Interrupt(early_return) = run_iteration_block { @@ -145,10 +147,8 @@ pub fn synthesise_iteration( let break_event = Event::Conditionally { condition, true_events: Default::default(), - else_events: Box::new([ - FinalEvent::Break { position: None, carry: 0 }.into() - ]), - position: None, + else_events: Box::new([FinalEvent::Break { position, carry: 0 }.into()]), + position, }; environment.info.events.push(break_event); @@ -184,6 +184,7 @@ pub fn synthesise_iteration( // TODO shouldn't be needed &mut Default::default(), &mut checking_data.types, + position, ); if let ApplicationResult::Interrupt(early_return) = run_iteration_block { todo!("{early_return:?}") @@ -242,11 +243,11 @@ pub fn synthesise_iteration( condition, true_events: Default::default(), else_events: Box::new([FinalEvent::Break { - position: None, + position, carry: 0, } .into()]), - position: None, + position, }; environment.info.events.push(break_event); @@ -317,6 +318,7 @@ pub fn synthesise_iteration( // TODO shouldn't be needed &mut Default::default(), &mut checking_data.types, + position, ); if let ApplicationResult::Interrupt(early_return) = run_iteration_block { todo!("{early_return:?}") @@ -357,6 +359,7 @@ pub fn synthesise_iteration( // TODO shouldn't be needed &mut Default::default(), &mut checking_data.types, + position, ); if let ApplicationResult::Interrupt(early_return) = run_iteration_block { todo!("{early_return:?}") @@ -401,6 +404,7 @@ pub(crate) fn run_iteration_block( invocation_context: &mut InvocationContext, errors: &mut ErrorsAndInfo, types: &mut TypeStore, + position: SpanWithSource, ) -> ApplicationResult { /// TODO via config and per line const MAX_ITERATIONS: usize = 100; @@ -452,6 +456,7 @@ pub(crate) fn run_iteration_block( invocation_context, errors, types, + position, ); if let ApplicationResult::Interrupt(result) = result { @@ -517,6 +522,7 @@ pub(crate) fn run_iteration_block( invocation_context, errors, types, + position, ); if let ApplicationResult::Interrupt(result) = result { @@ -647,6 +653,7 @@ fn evaluate_single_loop_iteration( invocation_context: &mut InvocationContext, errors: &mut ErrorsAndInfo, types: &mut TypeStore, + position: SpanWithSource, ) -> ApplicationResult { let final_event = invocation_context.new_loop_iteration(|invocation_context| { for event in events { @@ -660,6 +667,7 @@ fn evaluate_single_loop_iteration( invocation_context, types, errors, + position, ); if result.is_it_so_over() { diff --git a/checker/src/features/modules.rs b/checker/src/features/modules.rs index 15ef2073..9cc516fb 100644 --- a/checker/src/features/modules.rs +++ b/checker/src/features/modules.rs @@ -127,7 +127,7 @@ pub fn import_items< checking_data.diagnostics_container.add_error( crate::diagnostics::TypeCheckError::CannotOpenFile { file: err.clone(), - position: Some(import_position.with_source(environment.get_source())), + import_position: Some(import_position.with_source(environment.get_source())), }, ); } diff --git a/checker/src/features/objects.rs b/checker/src/features/objects.rs index c9581752..feb14435 100644 --- a/checker/src/features/objects.rs +++ b/checker/src/features/objects.rs @@ -23,11 +23,12 @@ impl ObjectBuilder { pub fn new( prototype: Option, types: &mut TypeStore, + position: SpanWithSource, info: &mut LocalInformation, ) -> Self { // TODO is_under_dyn bad let is_under_dyn = true; - Self { object: info.new_object(prototype, types, is_under_dyn, false) } + Self { object: info.new_object(prototype, types, position, is_under_dyn, false) } } pub fn append( @@ -36,7 +37,7 @@ impl ObjectBuilder { publicity: Publicity, under: PropertyKey<'static>, value: PropertyValue, - position: Option, + position: SpanWithSource, ) { environment.info.register_property(self.object, publicity, under, value, true, position); } diff --git a/checker/src/features/template_literal.rs b/checker/src/features/template_literal.rs index 47c806b7..66a5074b 100644 --- a/checker/src/features/template_literal.rs +++ b/checker/src/features/template_literal.rs @@ -1,4 +1,4 @@ -use source_map::Span; +use source_map::SpanWithSource; use crate::{ context::invocation::CheckThings, @@ -17,7 +17,7 @@ pub enum TemplateLiteralPart<'a, T> { pub fn synthesise_template_literal_expression<'a, T, A>( tag: Option, mut parts_iter: impl Iterator>> + 'a, - position: &Span, + position: SpanWithSource, environment: &mut Environment, checking_data: &mut CheckingData, ) -> TypeId @@ -60,6 +60,7 @@ where let mut static_parts = ObjectBuilder::new( Some(TypeId::ARRAY_TYPE), &mut checking_data.types, + position, &mut environment.info, ); @@ -76,7 +77,7 @@ where crate::types::properties::PropertyKey::from_usize(static_part_count.into()), crate::PropertyValue::Value(value), // TODO should static parts should have position? - None, + position, ); static_part_count += 1; } @@ -103,7 +104,7 @@ where crate::context::information::Publicity::Public, crate::types::properties::PropertyKey::String("length".into()), crate::types::properties::PropertyValue::Value(length), - None, + position, ); } @@ -117,13 +118,11 @@ where }, ); - let call_site = position.with_source(environment.get_source()); - let mut check_things = CheckThings { debug_types: checking_data.options.debug_types }; let input = CallingInput { called_with_new: crate::types::calling::CalledWithNew::None, - call_site, + call_site: position, call_site_type_arguments: None, }; match crate::types::calling::call_type( diff --git a/checker/src/lib.rs b/checker/src/lib.rs index 0ddbfb84..b195ff3c 100644 --- a/checker/src/lib.rs +++ b/checker/src/lib.rs @@ -519,7 +519,7 @@ pub fn check_project( } else { checking_data.diagnostics_container.add_error(TypeCheckError::CannotOpenFile { file: CouldNotOpenFile(point.clone()), - position: None, + import_position: None, }); continue; } diff --git a/checker/src/synthesis/classes.rs b/checker/src/synthesis/classes.rs index 9a95d604..53b3950b 100644 --- a/checker/src/synthesis/classes.rs +++ b/checker/src/synthesis/classes.rs @@ -160,7 +160,7 @@ pub(super) fn synthesise_class_declaration< is_declare, ); - let position = Some(method.position.with_source(environment.get_source())); + let position = method.position.with_source(environment.get_source()); environment.info.register_property( class_prototype, @@ -227,6 +227,7 @@ pub(super) fn synthesise_class_declaration< ClassPropertiesToRegister { properties }, environment, checking_data, + class.position.with_source(environment.get_source()), ) }; @@ -295,7 +296,7 @@ pub(super) fn synthesise_class_declaration< // TODO true, // TODO not needed right? - None, + method.position.with_source(environment.get_source()), ); } ClassMember::Property(true, property) => { @@ -330,7 +331,7 @@ pub(super) fn synthesise_class_declaration< // TODO true, // TODO not needed right? - None, + property.position.with_source(environment.get_source()), ); } ClassMember::StaticBlock(block) => { @@ -494,7 +495,7 @@ pub(super) fn register_statement_class_with_members( under, PropertyValue::Value(value), false, - None, + method.position.with_source(environment.get_source()), ); } ClassMember::Property(_is_static, property) => { @@ -515,7 +516,7 @@ pub(super) fn register_statement_class_with_members( under, PropertyValue::Value(value), false, - None, + property.position.with_source(environment.get_source()), ); } ClassMember::Indexer { @@ -523,7 +524,7 @@ pub(super) fn register_statement_class_with_members( indexer_type, return_type, is_readonly: _, - position: _, + position, } => { crate::utilities::notify!("Warn if not declare"); // TODO think this is okay @@ -535,7 +536,7 @@ pub(super) fn register_statement_class_with_members( PropertyKey::Type(key), PropertyValue::Value(value), false, - None, + position.with_source(environment.get_source()), ); } ClassMember::Constructor(_) diff --git a/checker/src/synthesis/expressions.rs b/checker/src/synthesis/expressions.rs index 9fd12a56..f60527fe 100644 --- a/checker/src/synthesis/expressions.rs +++ b/checker/src/synthesis/expressions.rs @@ -13,6 +13,7 @@ use parser::{ functions::MethodHeader, ASTNode, Expression, }; +use source_map::SpanWithSource; use crate::{ context::{ @@ -147,6 +148,7 @@ pub(super) fn synthesise_expression( let mut basis = ObjectBuilder::new( Some(TypeId::ARRAY_TYPE), &mut checking_data.types, + expression.get_position().with_source(environment.get_source()), &mut environment.info, ); @@ -163,7 +165,7 @@ pub(super) fn synthesise_expression( Publicity::Public, key, crate::types::properties::PropertyValue::Value(value), - Some(spread_expression_position), + spread_expression_position, ); } } @@ -173,14 +175,15 @@ pub(super) fn synthesise_expression( let length = checking_data.types.new_constant_type(Constant::Number( (elements.len() as f64).try_into().unwrap(), )); + let value = crate::types::properties::PropertyValue::Value(length); // TODO: Should there be a position here? basis.append( environment, Publicity::Public, PropertyKey::String("length".into()), - crate::types::properties::PropertyValue::Value(length), - None, + value, + expression.get_position().with_source(environment.get_source()), ); } @@ -190,6 +193,7 @@ pub(super) fn synthesise_expression( object_literal, checking_data, environment, + object_literal.position.with_source(environment.get_source()), expecting, )), Expression::TemplateLiteral(TemplateLiteral { tag, parts, position }) => { @@ -208,7 +212,7 @@ pub(super) fn synthesise_expression( Instance::RValue(synthesise_template_literal_expression( tag, parts_iter, - position, + position.with_source(environment.get_source()), environment, checking_data, )) @@ -380,6 +384,7 @@ pub(super) fn synthesise_expression( let result = environment.delete_property( on, &PropertyKey::String(Cow::Owned(property.clone())), + parent.get_position().with_source(environment.get_source()), ); return if result { TypeId::TRUE } else { TypeId::FALSE }; } @@ -404,7 +409,11 @@ pub(super) fn synthesise_expression( ); let property = PropertyKey::from_type(indexer, &checking_data.types); - let result = environment.delete_property(being_indexed, &property); + let result = environment.delete_property( + being_indexed, + &property, + indexee.get_position().with_source(environment.get_source()), + ); return if result { TypeId::TRUE } else { TypeId::FALSE }; } _ => { @@ -995,10 +1004,11 @@ pub(super) fn synthesise_object_literal( ObjectLiteral { members, .. }: &ObjectLiteral, checking_data: &mut CheckingData, environment: &mut Environment, + position: SpanWithSource, expected: TypeId, ) -> TypeId { let mut object_builder = - ObjectBuilder::new(None, &mut checking_data.types, &mut environment.info); + ObjectBuilder::new(None, &mut checking_data.types, position, &mut environment.info); for member in members { let member_position = member.get_position().with_source(environment.get_source()); @@ -1019,7 +1029,7 @@ pub(super) fn synthesise_object_literal( key, // TODO what about getters crate::PropertyValue::Value(value), - Some(pos.with_source(environment.get_source())), + pos.with_source(environment.get_source()), ); } } @@ -1049,7 +1059,7 @@ pub(super) fn synthesise_object_literal( Publicity::Public, key, crate::types::properties::PropertyValue::Value(value), - Some(member_position), + member_position, ); } ObjectLiteralMember::Property { key, value, position, .. } => { @@ -1105,13 +1115,7 @@ pub(super) fn synthesise_object_literal( synthesise_expression(value, environment, checking_data, property_expecting); let value = crate::types::properties::PropertyValue::Value(value); - object_builder.append( - environment, - Publicity::Public, - key, - value, - Some(member_position), - ); + object_builder.append(environment, Publicity::Public, key, value, member_position); // let property_name: PropertyName<'static> = property_key.into(); @@ -1174,7 +1178,7 @@ pub(super) fn synthesise_object_literal( Publicity::Public, key, property, - Some(member_position), + member_position, ); } } diff --git a/checker/src/synthesis/extensions/jsx.rs b/checker/src/synthesis/extensions/jsx.rs index 1e6f22e2..b958fede 100644 --- a/checker/src/synthesis/extensions/jsx.rs +++ b/checker/src/synthesis/extensions/jsx.rs @@ -41,8 +41,12 @@ pub(crate) fn synthesise_jsx_element( let tag_name_as_cst_ty = checking_data.types.new_constant_type(Constant::String(element.tag_name.clone())); - let mut attributes_object = - ObjectBuilder::new(None, &mut checking_data.types, &mut environment.info); + let mut attributes_object = ObjectBuilder::new( + None, + &mut checking_data.types, + element.position.with_source(environment.get_source()), + &mut environment.info, + ); for attribute in &element.attributes { let (name, attribute_value) = synthesise_attribute(attribute, environment, checking_data); @@ -52,7 +56,7 @@ pub(crate) fn synthesise_jsx_element( crate::context::information::Publicity::Public, name, crate::PropertyValue::Value(attribute_value), - Some(attribute_position), + attribute_position, ); // let constraint = environment @@ -131,6 +135,7 @@ pub(crate) fn synthesise_jsx_element( let mut synthesised_child_nodes = ObjectBuilder::new( Some(TypeId::ARRAY_TYPE), &mut checking_data.types, + element.position.with_source(environment.get_source()), &mut environment.info, ); @@ -151,7 +156,7 @@ pub(crate) fn synthesise_jsx_element( crate::context::information::Publicity::Public, property, crate::PropertyValue::Value(child), - Some(child_position), + child_position, ); // TODO spread ?? @@ -170,7 +175,7 @@ pub(crate) fn synthesise_jsx_element( crate::context::information::Publicity::Public, crate::types::properties::PropertyKey::String("length".into()), crate::types::properties::PropertyValue::Value(length), - None, + element.get_position().with_source(environment.get_source()), ); } diff --git a/checker/src/synthesis/interfaces.rs b/checker/src/synthesis/interfaces.rs index 8f6cf6c4..e0715fa2 100644 --- a/checker/src/synthesis/interfaces.rs +++ b/checker/src/synthesis/interfaces.rs @@ -2,6 +2,7 @@ use parser::{ types::interface::{InterfaceDeclaration, InterfaceMember}, Decorated, PropertyKey as ParserPropertyKey, WithComment, }; +use source_map::SpanWithSource; use crate::{ context::{information::Publicity, Context, Environment}, @@ -42,6 +43,7 @@ pub(crate) trait SynthesiseInterfaceBehavior { value: InterfaceValue, checking_data: &mut CheckingData, environment: &mut Environment, + position: SpanWithSource, ); fn interface_type(&self) -> Option; @@ -68,6 +70,7 @@ impl SynthesiseInterfaceBehavior for OnToType { value: InterfaceValue, checking_data: &mut CheckingData, environment: &mut Environment, + position: SpanWithSource, ) { let (publicity, under) = match key { ParserPropertyKeyType::ClassProperty(key) => { @@ -121,7 +124,7 @@ impl SynthesiseInterfaceBehavior for OnToType { }; // None position should be fine here - environment.info.register_property(self.0, publicity, under, ty, false, None); + environment.info.register_property(self.0, publicity, under, ty, false, position); } fn interface_type(&self) -> Option { @@ -177,13 +180,15 @@ pub(super) fn synthesise_signatures GetterSetter::None, }; + let position_with_source = position.with_source(environment.get_source()); + let function = synthesise_function_annotation( type_parameters, parameters, return_type.as_ref(), environment, checking_data, - &position.with_source(environment.get_source()), + &position_with_source, behavior, ); @@ -192,6 +197,7 @@ pub(super) fn synthesise_signatures { // TODO think this is okay let key = synthesise_type_annotation(indexer_type, environment, checking_data); @@ -239,6 +246,7 @@ pub(super) fn synthesise_signatures { // TODO WIP let to = match rule { @@ -296,6 +304,7 @@ pub(super) fn synthesise_signatures {} diff --git a/checker/src/synthesis/statements.rs b/checker/src/synthesis/statements.rs index a140c5d2..688a8a08 100644 --- a/checker/src/synthesis/statements.rs +++ b/checker/src/synthesis/statements.rs @@ -31,6 +31,7 @@ pub(super) fn synthesise_statement( environment: &mut Environment, checking_data: &mut CheckingData, ) { + let position = statement.get_position().with_source(environment.get_source()); match statement { Statement::Expression(expression) => { synthesise_multiple_expression( @@ -115,6 +116,7 @@ pub(super) fn synthesise_statement( |environment, checking_data| { synthesise_block_or_single_statement(&stmt.inner, environment, checking_data); }, + position, ), Statement::DoWhileLoop(stmt) => synthesise_iteration( IterationBehavior::DoWhile(&stmt.condition), @@ -124,6 +126,7 @@ pub(super) fn synthesise_statement( |environment, checking_data| { synthesise_block_or_single_statement(&stmt.inner, environment, checking_data); }, + position, ), Statement::ForLoop(stmt) => match &stmt.condition { parser::statements::ForLoopCondition::ForOf { @@ -131,7 +134,7 @@ pub(super) fn synthesise_statement( keyword: _, variable, of, - position: _, + position, } => { synthesise_iteration( IterationBehavior::ForOf { lhs: variable.get_ast_ref(), rhs: of }, @@ -145,13 +148,14 @@ pub(super) fn synthesise_statement( checking_data, ); }, + position.with_source(environment.get_source()), ); } parser::statements::ForLoopCondition::ForIn { keyword: _, variable, r#in, - position: _, + position, } => { synthesise_iteration( IterationBehavior::ForIn { lhs: variable.get_ast_ref(), rhs: r#in }, @@ -165,13 +169,14 @@ pub(super) fn synthesise_statement( checking_data, ); }, + position.with_source(environment.get_source()), ); } parser::statements::ForLoopCondition::Statements { initialiser, condition, afterthought, - position: _, + position, } => synthesise_iteration( IterationBehavior::For { initialiser, condition, afterthought }, information.and_then(|info| info.label), @@ -180,6 +185,7 @@ pub(super) fn synthesise_statement( |environment, checking_data| { synthesise_block_or_single_statement(&stmt.inner, environment, checking_data); }, + position.with_source(environment.get_source()), ), }, Statement::Block(ref block) => { diff --git a/checker/src/synthesis/type_annotations.rs b/checker/src/synthesis/type_annotations.rs index 37331c05..02f1e647 100644 --- a/checker/src/synthesis/type_annotations.rs +++ b/checker/src/synthesis/type_annotations.rs @@ -364,11 +364,12 @@ pub(super) fn synthesise_type_annotation( ) .0 } - TypeAnnotation::TupleLiteral(members, _) => { + TypeAnnotation::TupleLiteral(members, position) => { // TODO maybe should be special type let mut obj = ObjectBuilder::new( Some(TypeId::ARRAY_TYPE), &mut checking_data.types, + position.with_source(environment.get_source()), &mut environment.info, ); @@ -392,7 +393,7 @@ pub(super) fn synthesise_type_annotation( Publicity::Public, PropertyKey::from_usize(idx), PropertyValue::Value(item_ty), - Some(ty_position), + ty_position, ); } TupleElementKind::Optional => { @@ -413,7 +414,7 @@ pub(super) fn synthesise_type_annotation( Publicity::Public, PropertyKey::String("length".into()), PropertyValue::Value(length_value), - None, + annotation.get_position().with_source(environment.get_source()), ); obj.build_object() diff --git a/checker/src/types/calling.rs b/checker/src/types/calling.rs index d1432159..318994fb 100644 --- a/checker/src/types/calling.rs +++ b/checker/src/types/calling.rs @@ -503,20 +503,20 @@ pub enum FunctionCallingError { TDZ { error: TDZ, /// Should be set - call_site: Option, + call_site: SpanWithSource, }, SetPropertyConstraint { property_type: TypeStringRepresentation, value_type: TypeStringRepresentation, assignment_position: SpanWithSource, /// Should be set - call_site: Option, + call_site: SpanWithSource, }, /// TODO WIP UnconditionalThrow { value: TypeStringRepresentation, /// Should be set - call_site: Option, + call_site: SpanWithSource, }, MismatchedThis { expected: TypeStringRepresentation, @@ -620,6 +620,7 @@ impl FunctionType { arguments, types, environment, + call_site, ); match result { @@ -872,6 +873,7 @@ impl FunctionType { target, types, errors, + call_site, ); // Adjust call sites. (because they aren't currently passed down) @@ -882,7 +884,7 @@ impl FunctionType { } | FunctionCallingError::UnconditionalThrow { call_site: ref mut c, .. } = d { - *c = Some(call_site); + *c = call_site; } } @@ -1140,8 +1142,12 @@ impl FunctionType { if self.parameters.parameters.len() < arguments.len() { if let Some(ref rest_parameter) = self.parameters.rest_parameter { // TODO reuse synthesise_array literal logic (especially for spread items) - let mut basis = - ObjectBuilder::new(Some(TypeId::ARRAY_TYPE), types, &mut environment.info); + let mut basis = ObjectBuilder::new( + Some(TypeId::ARRAY_TYPE), + types, + rest_parameter.position, + &mut environment.info, + ); let mut count = 0; @@ -1196,7 +1202,7 @@ impl FunctionType { crate::context::information::Publicity::Public, key, crate::types::properties::PropertyValue::Value(argument.value), - None, + argument.position, ); } @@ -1213,7 +1219,7 @@ impl FunctionType { crate::context::information::Publicity::Public, PropertyKey::String("length".into()), crate::types::properties::PropertyValue::Value(length), - None, + rest_parameter.position, ); } diff --git a/checker/src/types/classes.rs b/checker/src/types/classes.rs index 9ea3b455..84d12dcd 100644 --- a/checker/src/types/classes.rs +++ b/checker/src/types/classes.rs @@ -1,3 +1,5 @@ +use source_map::SpanWithSource; + use crate::{ context::information::Publicity, events::Event, features::functions::ClassPropertiesToRegister, CheckingData, Environment, PropertyValue, TypeId, @@ -48,6 +50,7 @@ fn _register_properties_into_store, checking_data: &mut CheckingData, + position: SpanWithSource, ) { let scope = crate::Scope::Function(crate::context::environment::FunctionScope::Constructor { extends: false, @@ -65,6 +68,7 @@ fn _register_properties_into_store, ClassPropertiesToRegister { properties }: ClassPropertiesToRegister, + position: SpanWithSource, ) { for ClassValue { publicity, key, value } in properties { let value = if let Some(expression) = value { @@ -94,6 +99,6 @@ pub(crate) fn register_properties_into_environment< } else { PropertyValue::Value(TypeId::UNDEFINED_TYPE) }; - environment.info.register_property(on, publicity, key, value, true, None); + environment.info.register_property(on, publicity, key, value, true, position); } } diff --git a/checker/src/types/functions.rs b/checker/src/types/functions.rs index 7edc4f78..fb98a31d 100644 --- a/checker/src/types/functions.rs +++ b/checker/src/types/functions.rs @@ -75,6 +75,7 @@ impl FunctionType { properties: ClassPropertiesToRegister, environment: &mut Environment, checking_data: &mut CheckingData, + position: SpanWithSource, ) -> Self { let scope = Scope::Function(FunctionScope::Constructor { extends: false, @@ -91,6 +92,7 @@ impl FunctionType { &mut checking_data.types, &mut environment.info, class_prototype, + position, ); if let Scope::Function(FunctionScope::Constructor { ref mut this_object_type, @@ -120,7 +122,13 @@ impl FunctionType { ); } - register_properties_into_environment(environment, on, checking_data, properties); + register_properties_into_environment( + environment, + on, + checking_data, + properties, + position, + ); on }, @@ -150,6 +158,7 @@ pub(crate) fn create_this_before_function_synthesis( types: &mut TypeStore, info: &mut LocalInformation, prototype: TypeId, + position: SpanWithSource, ) -> TypeId { let ty = types.register_type(Type::Object(crate::types::ObjectNature::RealDeal)); @@ -158,7 +167,7 @@ pub(crate) fn create_this_before_function_synthesis( let value = Event::CreateObject { referenced_in_scope_as: ty, prototype: crate::events::PrototypeArgument::Yeah(prototype), - position: None, + position, // TODO right? is_function_this: true, }; diff --git a/checker/src/types/others.rs b/checker/src/types/others.rs index 236a9c24..f9aa0713 100644 --- a/checker/src/types/others.rs +++ b/checker/src/types/others.rs @@ -1,5 +1,7 @@ // Types to runtime behavior +use source_map::SpanWithSource; + use crate::{ context::information::{get_properties_on_type, Publicity}, features::objects::{ObjectBuilder, SpecialObjects}, @@ -14,8 +16,9 @@ pub(crate) fn create_object_for_type( environment: &mut Environment, // &mut to create new objects types: &mut TypeStore, + call_site: SpanWithSource, ) -> TypeId { - let mut obj = ObjectBuilder::new(None, types, &mut environment.info); + let mut obj = ObjectBuilder::new(None, types, call_site, &mut environment.info); match types.get_type_by_id(ty) { Type::AliasTo { to: _, name: _, parameters: _ } => todo!(), ty @ (Type::And(left, right) | Type::Or(left, right)) => { @@ -28,23 +31,23 @@ pub(crate) fn create_object_for_type( Publicity::Public, PropertyKey::String("kind".into()), crate::PropertyValue::Value(types.new_constant_type(Constant::String(kind.into()))), - None, + call_site, ); - let left = create_object_for_type(left, environment, types); - let right = create_object_for_type(right, environment, types); + let left = create_object_for_type(left, environment, types, call_site); + let right = create_object_for_type(right, environment, types, call_site); obj.append( environment, Publicity::Public, PropertyKey::String("left".into()), crate::PropertyValue::Value(left), - None, + call_site, ); obj.append( environment, Publicity::Public, PropertyKey::String("right".into()), crate::PropertyValue::Value(right), - None, + call_site, ); } Type::RootPolyType(_) => todo!(), @@ -58,22 +61,23 @@ pub(crate) fn create_object_for_type( Publicity::Public, PropertyKey::String("name".into()), crate::PropertyValue::Value(types.new_constant_type(Constant::String(name))), - None, + call_site, ); if !matches!(ty, TypeId::BOOLEAN_TYPE | TypeId::STRING_TYPE | TypeId::NUMBER_TYPE) { // TODO array - let mut inner_object = ObjectBuilder::new(None, types, &mut environment.info); + let mut inner_object = + ObjectBuilder::new(None, types, call_site, &mut environment.info); // let properties = env.create_array(); for (_, key, property) in get_properties_on_type(ty, types, environment) { - let value = create_object_for_type(property, environment, types); + let value = create_object_for_type(property, environment, types, call_site); inner_object.append( environment, Publicity::Public, key, crate::PropertyValue::Value(value), - None, + call_site, ); } @@ -82,7 +86,7 @@ pub(crate) fn create_object_for_type( Publicity::Public, PropertyKey::String("properties".into()), crate::PropertyValue::Value(inner_object.build_object()), - None, + call_site, ); } } @@ -92,7 +96,7 @@ pub(crate) fn create_object_for_type( Publicity::Public, PropertyKey::String("constant".into()), crate::PropertyValue::Value(ty), - None, + call_site, ); } Type::SpecialObject(SpecialObjects::Function(..)) => todo!(), @@ -106,21 +110,22 @@ pub(crate) fn create_object_for_type( Publicity::Public, PropertyKey::String("kind".into()), value, - None, + call_site, ); // TODO array - let mut inner_object = ObjectBuilder::new(None, types, &mut environment.info); + let mut inner_object = + ObjectBuilder::new(None, types, call_site, &mut environment.info); // let properties = env.create_array(); for (_, key, property) in get_properties_on_type(ty, types, environment) { - let value = create_object_for_type(property, environment, types); + let value = create_object_for_type(property, environment, types, call_site); inner_object.append( environment, Publicity::Public, key, crate::PropertyValue::Value(value), - None, + call_site, ); } @@ -129,7 +134,7 @@ pub(crate) fn create_object_for_type( Publicity::Public, PropertyKey::String("properties".into()), crate::PropertyValue::Value(inner_object.build_object()), - None, + call_site, ); } Type::SpecialObject(_) => todo!(), diff --git a/checker/src/types/properties.rs b/checker/src/types/properties.rs index 74b0233b..6252ae45 100644 --- a/checker/src/types/properties.rs +++ b/checker/src/types/properties.rs @@ -613,7 +613,7 @@ pub(crate) fn set_property( environment: &mut Environment, behavior: &mut E, types: &mut TypeStore, - setter_position: Option, + setter_position: SpanWithSource, ) -> Result, SetPropertyError> { // TODO // if environment.is_not_writeable(on, under) { @@ -823,7 +823,7 @@ fn run_setter_on_object( under: &PropertyKey<'_>, new: PropertyValue, types: &mut TypeStore, - setter_position: Option, + setter_position: SpanWithSource, ) -> Result<(), Vec> { match og { PropertyValue::Deleted | PropertyValue::Value(..) => { @@ -846,12 +846,8 @@ fn run_setter_on_object( } PropertyValue::Getter(_) => todo!(), PropertyValue::Setter(setter) => { - // TODO: FunctionType.Call requires a SpanWithSource but here we have an - // Option. However, updating this function to require a SpanWithSource - // would mean fairly broad changes. - let some_setter_position = setter_position.expect("Setter position is required!"); let arg = SynthesisedArgument { - position: some_setter_position, + position: setter_position, spread: false, value: match new { PropertyValue::Value(type_id) => type_id, @@ -863,7 +859,7 @@ fn run_setter_on_object( .call( CalledWithNew::None, ThisValue::Passed(on), - some_setter_position, + setter_position, &[arg], None, // TODO structure generics diff --git a/src/reporting.rs b/src/reporting.rs index 5387d0f3..6e0578fb 100644 --- a/src/reporting.rs +++ b/src/reporting.rs @@ -65,13 +65,9 @@ fn checker_diagnostic_to_codespan_diagnostic( diagnostic.labels.push(main_label); for (message, position) in labels { - if let Some(position) = position { - diagnostic.labels.push( - Label::secondary(position.source, position).with_message(message), - ); - } else { - diagnostic.notes.push(message) - } + diagnostic + .labels + .push(Label::secondary(position.source, position).with_message(message)); } }