Actually just three programming languages in a trenchcoat
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix compiler crash when assigning to non-assignable expression

+36 -7
+4
trilogy-ir/src/error.rs
··· 30 30 name: ir::Identifier, 31 31 assignment: Span, 32 32 }, 33 + InvalidAssignmentTarget { 34 + target: Span, 35 + }, 33 36 DuplicateExport { 34 37 original: Span, 35 38 duplicate: syntax::Identifier, ··· 81 84 Error::DuplicateDefinition { .. } => write!(f, "duplicate definition"), 82 85 Error::IdentifierInOwnDefinition { .. } => write!(f, "identifier in own definition"), 83 86 Error::AssignedImmutableBinding { .. } => write!(f, "assigned immutable binding"), 87 + Error::InvalidAssignmentTarget { .. } => write!(f, "invalid assignment target"), 84 88 Error::DuplicateExport { .. } => write!(f, "duplicate export"), 85 89 Error::BecomeOutsideHandlerContext { .. } => { 86 90 write!(f, "become used outside of handler")
+20 -7
trilogy-ir/src/ir/assignment.rs
··· 21 21 22 22 let op = match ast.strategy { 23 23 Direct(..) => { 24 - if let expression::Value::Reference(id) = &lhs.value 25 - && !id.is_mutable 26 - { 27 - converter.error(Error::AssignedImmutableBinding { 28 - name: *id.clone(), 29 - assignment: span, 30 - }); 24 + match &lhs.value { 25 + expression::Value::Reference(id) => { 26 + if !id.is_mutable { 27 + converter.error(Error::AssignedImmutableBinding { 28 + name: *id.clone(), 29 + assignment: span, 30 + }); 31 + } 32 + } 33 + expression::Value::Application(app) => match &app.function.value { 34 + expression::Value::Application(app_fn) 35 + if matches!(app_fn.function.value, Value::Builtin(Builtin::Access)) => { 36 + } 37 + _ => { 38 + converter.error(Error::InvalidAssignmentTarget { target: lhs.span }); 39 + } 40 + }, 41 + _ => { 42 + converter.error(Error::InvalidAssignmentTarget { target: lhs.span }); 43 + } 31 44 } 32 45 return Expression::assignment(span, Assignment { lhs, rhs }); 33 46 }
+12
trilogy/src/trilogy/builder/report.rs
··· 211 211 name.id.name(), 212 212 )) 213 213 } 214 + Error::InvalidAssignmentTarget { target } => { 215 + let span = cache.span(location, *target); 216 + ariadne::Report::build(kind, span.clone()) 217 + .with_message("invalid assignment target") 218 + .with_label( 219 + Label::new(span) 220 + .with_color(primary) 221 + .with_message("this expression is not assignable") 222 + .with_order(1), 223 + ) 224 + .with_help("only single identifiers or member access expressions (`.`) can be assigned to") 225 + } 214 226 Error::GluePatternMissingLiteral { lhs, glue, rhs } => { 215 227 let lhs = cache.span(location, *lhs); 216 228 let glue = cache.span(location, *glue);