Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

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

show unchanged fields even when on ..

author
Giacomo Cavalieri
committer
Louis Pilfold
date (May 18, 2026, 3:51 PM +0100) commit 0b778b12 parent a88023f3 change-id xnktknnt
+93 -2
+26
compiler-core/src/ast/typed.rs
··· 177 177 /// we do for pipelines. 178 178 RecordUpdate { 179 179 location: SrcSpan, 180 + /// This is where the `..` starts: 181 + /// ```gleam 182 + /// Wibble( ..wobble, a: 1) 183 + /// // ^ Here! 184 + /// ``` 185 + spread_start: u32, 180 186 type_: Arc<Type>, 181 187 /// This is the record being updated as written in the code: 182 188 /// ```gleam ··· 438 444 constructor, 439 445 arguments, 440 446 updated_record, 447 + spread_start, 441 448 .. 442 449 } => arguments 443 450 .iter() ··· 466 473 } else { 467 474 found 468 475 } 476 + }) 477 + }) 478 + .or_else(|| { 479 + // If we're hovering over the two `..` then we also want to 480 + // count that as hovering the entire expression and show the 481 + // fields that are not being updated. 482 + if !SrcSpan::new(*spread_start, updated_record.location().start) 483 + .contains(byte_index) 484 + { 485 + return None; 486 + } 487 + 488 + Some(Located::Expression { 489 + expression: self, 490 + position: ExpressionPosition::UpdatedRecord { 491 + unchanged_record_fields: self 492 + .unchanged_record_fields() 493 + .unwrap_or_default(), 494 + }, 469 495 }) 470 496 }) 471 497 .or_else(|| self.self_if_contains_location(byte_index)),
+6
compiler-core/src/ast/untyped.rs
··· 132 132 133 133 RecordUpdate { 134 134 location: SrcSpan, 135 + /// This is where the `..` starts: 136 + /// ```gleam 137 + /// Wibble( ..wobble, a: 1) 138 + /// // ^ Here! 139 + /// ``` 140 + spread_start: u32, 135 141 constructor: Box<Self>, 136 142 record: RecordBeingUpdated<UntypedExpr>, 137 143 arguments: Vec<UntypedRecordUpdateArg>,
+7
compiler-core/src/ast/visit.rs
··· 326 326 visit_typed_expr_bit_array(self, location, type_, segments); 327 327 } 328 328 329 + #[allow(clippy::too_many_arguments)] 329 330 fn visit_typed_expr_record_update( 330 331 &mut self, 331 332 location: &'ast SrcSpan, 333 + spread_start: &'ast u32, 332 334 type_: &'ast Arc<Type>, 333 335 updated_record: &'ast TypedExpr, 334 336 updated_record_assigned_name: &'ast Option<EcoString>, ··· 338 340 visit_typed_expr_record_update( 339 341 self, 340 342 location, 343 + spread_start, 341 344 type_, 342 345 updated_record, 343 346 updated_record_assigned_name, ··· 1383 1386 } => v.visit_typed_expr_bit_array(location, type_, segments), 1384 1387 TypedExpr::RecordUpdate { 1385 1388 location, 1389 + spread_start, 1386 1390 type_, 1387 1391 updated_record, 1388 1392 updated_record_assigned_name, ··· 1390 1394 arguments, 1391 1395 } => v.visit_typed_expr_record_update( 1392 1396 location, 1397 + spread_start, 1393 1398 type_, 1394 1399 updated_record, 1395 1400 updated_record_assigned_name, ··· 1703 1708 } 1704 1709 } 1705 1710 1711 + #[allow(clippy::too_many_arguments)] 1706 1712 pub fn visit_typed_expr_record_update<'a, V>( 1707 1713 v: &mut V, 1708 1714 _location: &'a SrcSpan, 1715 + _spread_start: &'a u32, 1709 1716 _type_: &'a Arc<Type>, 1710 1717 updated_record: &'a TypedExpr, 1711 1718 _updated_record_assigned_name: &'a Option<EcoString>,
+6 -1
compiler-core/src/ast_folder.rs
··· 350 350 351 351 UntypedExpr::RecordUpdate { 352 352 location, 353 + spread_start, 353 354 constructor, 354 355 record, 355 356 arguments, 356 - } => self.fold_record_update(location, constructor, record, arguments), 357 + } => self.fold_record_update(location, spread_start, constructor, record, arguments), 357 358 358 359 UntypedExpr::NegateBool { location, value } => self.fold_negate_bool(location, value), 359 360 ··· 573 574 574 575 UntypedExpr::RecordUpdate { 575 576 location, 577 + spread_start, 576 578 constructor, 577 579 record, 578 580 arguments, ··· 587 589 .collect(); 588 590 UntypedExpr::RecordUpdate { 589 591 location, 592 + spread_start, 590 593 constructor, 591 594 record, 592 595 arguments, ··· 906 909 fn fold_record_update( 907 910 &mut self, 908 911 location: SrcSpan, 912 + spread_start: u32, 909 913 constructor: Box<UntypedExpr>, 910 914 record: RecordBeingUpdated<UntypedExpr>, 911 915 arguments: Vec<UntypedRecordUpdateArg>, 912 916 ) -> UntypedExpr { 913 917 UntypedExpr::RecordUpdate { 914 918 location, 919 + spread_start, 915 920 constructor, 916 921 record, 917 922 arguments,
+2
compiler-core/src/inline.rs
··· 705 705 706 706 TypedExpr::RecordUpdate { 707 707 location, 708 + spread_start, 708 709 type_, 709 710 updated_record, 710 711 updated_record_assigned_name, ··· 712 713 arguments, 713 714 } => TypedExpr::RecordUpdate { 714 715 location, 716 + spread_start, 715 717 type_, 716 718 updated_record: Box::new(self.expression(*updated_record)), 717 719 updated_record_assigned_name,
+1
compiler-core/src/parse.rs
··· 983 983 984 984 expr = UntypedExpr::RecordUpdate { 985 985 location: SrcSpan { start, end }, 986 + spread_start: dot_s, 986 987 constructor: Box::new(expr), 987 988 record, 988 989 arguments,
+4 -1
compiler-core/src/type_/expression.rs
··· 543 543 544 544 UntypedExpr::RecordUpdate { 545 545 location, 546 + spread_start, 546 547 constructor, 547 548 record, 548 549 arguments, 549 - } => self.infer_record_update(*constructor, record, arguments, location), 550 + } => self.infer_record_update(*constructor, record, arguments, location, spread_start), 550 551 551 552 UntypedExpr::NegateBool { location, value } => { 552 553 Ok(self.infer_negate_bool(location, *value)) ··· 3019 3020 record: RecordBeingUpdated<UntypedExpr>, 3020 3021 arguments: Vec<UntypedRecordUpdateArg>, 3021 3022 location: SrcSpan, 3023 + spread_start: u32, 3022 3024 ) -> Result<TypedExpr, Error> { 3023 3025 // infer the constructor being used 3024 3026 let typed_constructor = self.infer_or_error(constructor.clone())?; ··· 3119 3121 3120 3122 Ok(TypedExpr::RecordUpdate { 3121 3123 location, 3124 + spread_start, 3122 3125 type_: variant.return_type, 3123 3126 updated_record: Box::new(record), 3124 3127 updated_record_assigned_name,
+4
language-server/src/code_action.rs
··· 3524 3524 fn visit_typed_expr_record_update( 3525 3525 &mut self, 3526 3526 location: &'ast SrcSpan, 3527 + spread_start: &'ast u32, 3527 3528 type_: &'ast Arc<Type>, 3528 3529 updated_record: &'ast TypedExpr, 3529 3530 updated_record_assigned_name: &'ast Option<EcoString>, ··· 3555 3556 ast::visit::visit_typed_expr_record_update( 3556 3557 self, 3557 3558 location, 3559 + spread_start, 3558 3560 type_, 3559 3561 updated_record, 3560 3562 updated_record_assigned_name, ··· 11862 11864 fn visit_typed_expr_record_update( 11863 11865 &mut self, 11864 11866 location: &'ast SrcSpan, 11867 + spread_start: &'ast u32, 11865 11868 type_: &'ast Arc<Type>, 11866 11869 updated_record: &'ast TypedExpr, 11867 11870 updated_record_assigned_name: &'ast Option<EcoString>, ··· 11886 11889 ast::visit::visit_typed_expr_record_update( 11887 11890 self, 11888 11891 location, 11892 + spread_start, 11889 11893 type_, 11890 11894 updated_record, 11891 11895 updated_record_assigned_name,
+16
language-server/src/tests/hover.rs
··· 2104 2104 } 2105 2105 2106 2106 #[test] 2107 + fn hover_on_record_dot_of_record_update_shows_ignored_fields() { 2108 + assert_hover!( 2109 + " 2110 + type Wibble { 2111 + Wibble(a: Int, b: Bool) 2112 + } 2113 + 2114 + pub fn go(wibble: Wibble) { 2115 + Wibble(..wibble, a: 1) 2116 + } 2117 + ", 2118 + find_position_of("..") 2119 + ); 2120 + } 2121 + 2122 + #[test] 2107 2123 fn hover_on_record_being_updated_shows_ignored_fields() { 2108 2124 assert_hover!( 2109 2125 "
+21
language-server/src/tests/snapshots/gleam_language_server__tests__hover__hover_on_record_dot_of_record_update_shows_ignored_fields.snap
··· 1 + --- 2 + source: language-server/src/tests/hover.rs 3 + expression: "\ntype Wibble {\n Wibble(a: Int, b: Bool)\n}\n\npub fn go(wibble: Wibble) {\n Wibble(..wibble, a: 1)\n}\n" 4 + --- 5 + 6 + type Wibble { 7 + Wibble(a: Int, b: Bool) 8 + } 9 + 10 + pub fn go(wibble: Wibble) { 11 + Wibble(..wibble, a: 1) 12 + ▔▔▔▔▔▔▔↑▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 + } 14 + 15 + 16 + ----- Hover content (markdown) ----- 17 + ```gleam 18 + Wibble 19 + ``` 20 + Unchanged record fields: 21 + - `b: Bool`