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

Configure Feed

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

Generate correct definitions for indexing named fields

author
GearsDatapacks
committer
Louis Pilfold
date (Sep 19, 2025, 11:58 AM +0100) commit ea2ff83f parent 377f9fa2 change-id nqzmuvvm
+79 -77
+13 -11
compiler-core/src/javascript.rs
··· 487 487 record_name = constructor.name, 488 488 ); 489 489 490 - let contents = docvec![break_("", " "), "value[", index, "];"].group(); 491 - 492 - functions.push(docvec![ 493 - line(), 494 - "export const ", 495 - function_name, 496 - " = (value) =>", 497 - contents.nest(INDENT), 498 - ]); 490 + let contents; 499 491 500 492 // If the argument is labelled, also generate a getter for the labelled 501 493 // argument. ··· 505 497 record_name = constructor.name, 506 498 ); 507 499 508 - let contents = 500 + contents = 509 501 docvec![break_("", " "), "value.", maybe_escape_property(label), ";"].group(); 510 502 511 503 functions.push(docvec![ ··· 513 505 "export const ", 514 506 function_name, 515 507 " = (value) =>", 516 - contents.nest(INDENT), 508 + contents.clone().nest(INDENT), 517 509 ]); 510 + } else { 511 + contents = docvec![break_("", " "), "value[", index, "];"].group() 518 512 } 513 + 514 + functions.push(docvec![ 515 + line(), 516 + "export const ", 517 + function_name, 518 + " = (value) =>", 519 + contents.nest(INDENT), 520 + ]); 519 521 } 520 522 521 523 concat(functions)
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_1.snap
··· 28 28 } 29 29 export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 30 export const Wibble$isWibble = (value) => value instanceof Wibble; 31 - export const Wibble$Wibble$0 = (value) => value[0]; 32 31 export const Wibble$Wibble$int = (value) => value.int; 33 - export const Wibble$Wibble$1 = (value) => value[1]; 32 + export const Wibble$Wibble$0 = (value) => value.int; 34 33 export const Wibble$Wibble$string = (value) => value.string; 34 + export const Wibble$Wibble$1 = (value) => value.string; 35 35 36 36 export class Wobble extends $CustomType { 37 37 constructor($0) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_2.snap
··· 28 28 } 29 29 export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 30 export const Wibble$isWibble = (value) => value instanceof Wibble; 31 - export const Wibble$Wibble$0 = (value) => value[0]; 32 31 export const Wibble$Wibble$int = (value) => value.int; 33 - export const Wibble$Wibble$1 = (value) => value[1]; 32 + export const Wibble$Wibble$0 = (value) => value.int; 34 33 export const Wibble$Wibble$string = (value) => value.string; 34 + export const Wibble$Wibble$1 = (value) => value.string; 35 35 36 36 export class Wobble extends $CustomType { 37 37 constructor($0) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_3.snap
··· 29 29 } 30 30 export const Wibble$Wibble = (int, string) => new Wibble(int, string); 31 31 export const Wibble$isWibble = (value) => value instanceof Wibble; 32 - export const Wibble$Wibble$0 = (value) => value[0]; 33 32 export const Wibble$Wibble$int = (value) => value.int; 34 - export const Wibble$Wibble$1 = (value) => value[1]; 33 + export const Wibble$Wibble$0 = (value) => value.int; 35 34 export const Wibble$Wibble$string = (value) => value.string; 35 + export const Wibble$Wibble$1 = (value) => value.string; 36 36 37 37 export class Wobble extends $CustomType { 38 38 constructor($0) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_4.snap
··· 28 28 } 29 29 export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 30 export const Wibble$isWibble = (value) => value instanceof Wibble; 31 - export const Wibble$Wibble$0 = (value) => value[0]; 32 31 export const Wibble$Wibble$int = (value) => value.int; 33 - export const Wibble$Wibble$1 = (value) => value[1]; 32 + export const Wibble$Wibble$0 = (value) => value.int; 34 33 export const Wibble$Wibble$string = (value) => value.string; 34 + export const Wibble$Wibble$1 = (value) => value.string; 35 35 36 36 export class Wobble extends $CustomType { 37 37 constructor($0) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_5.snap
··· 28 28 } 29 29 export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 30 export const Wibble$isWibble = (value) => value instanceof Wibble; 31 - export const Wibble$Wibble$0 = (value) => value[0]; 32 31 export const Wibble$Wibble$int = (value) => value.int; 33 - export const Wibble$Wibble$1 = (value) => value[1]; 32 + export const Wibble$Wibble$0 = (value) => value.int; 34 33 export const Wibble$Wibble$string = (value) => value.string; 34 + export const Wibble$Wibble$1 = (value) => value.string; 35 35 36 36 export class Wobble extends $CustomType { 37 37 constructor($0) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_6.snap
··· 28 28 } 29 29 export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 30 export const Wibble$isWibble = (value) => value instanceof Wibble; 31 - export const Wibble$Wibble$0 = (value) => value[0]; 32 31 export const Wibble$Wibble$int = (value) => value.int; 33 - export const Wibble$Wibble$1 = (value) => value[1]; 32 + export const Wibble$Wibble$0 = (value) => value.int; 34 33 export const Wibble$Wibble$string = (value) => value.string; 34 + export const Wibble$Wibble$1 = (value) => value.string; 35 35 36 36 export class Wobble extends $CustomType { 37 37 constructor($0) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__record_update_in_pipeline_in_case_clause.snap
··· 35 35 } 36 36 export const Wibble$Wibble = (wibble, wobble) => new Wibble(wibble, wobble); 37 37 export const Wibble$isWibble = (value) => value instanceof Wibble; 38 - export const Wibble$Wibble$0 = (value) => value[0]; 39 38 export const Wibble$Wibble$wibble = (value) => value.wibble; 40 - export const Wibble$Wibble$1 = (value) => value[1]; 39 + export const Wibble$Wibble$0 = (value) => value.wibble; 41 40 export const Wibble$Wibble$wobble = (value) => value.wobble; 41 + export const Wibble$Wibble$1 = (value) => value.wobble; 42 42 43 43 function identity(x) { 44 44 return x;
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__field_access.snap
··· 31 31 export const Person$Person = (username, name, age) => 32 32 new Person(username, name, age); 33 33 export const Person$isPerson = (value) => value instanceof Person; 34 - export const Person$Person$0 = (value) => value[0]; 35 34 export const Person$Person$username = (value) => value.username; 36 - export const Person$Person$1 = (value) => value[1]; 35 + export const Person$Person$0 = (value) => value.username; 37 36 export const Person$Person$name = (value) => value.name; 38 - export const Person$Person$2 = (value) => value[2]; 37 + export const Person$Person$1 = (value) => value.name; 39 38 export const Person$Person$age = (value) => value.age; 39 + export const Person$Person$2 = (value) => value.age; 40 40 41 41 export function main() { 42 42 let given_name = "jack";
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__nested_record_access.snap
··· 35 35 } 36 36 export const A$A = (b) => new A(b); 37 37 export const A$isA = (value) => value instanceof A; 38 - export const A$A$0 = (value) => value[0]; 39 38 export const A$A$b = (value) => value.b; 39 + export const A$A$0 = (value) => value.b; 40 40 41 41 export class B extends $CustomType { 42 42 constructor(c) { ··· 46 46 } 47 47 export const B$B = (c) => new B(c); 48 48 export const B$isB = (value) => value instanceof B; 49 - export const B$B$0 = (value) => value[0]; 50 49 export const B$B$c = (value) => value.c; 50 + export const B$B$0 = (value) => value.c; 51 51 52 52 export class C extends $CustomType { 53 53 constructor(d) { ··· 57 57 } 58 58 export const C$C = (d) => new C(d); 59 59 export const C$isC = (value) => value instanceof C; 60 - export const C$C$0 = (value) => value[0]; 61 60 export const C$C$d = (value) => value.d; 61 + export const C$C$0 = (value) => value.d; 62 62 63 63 export function a(a) { 64 64 if (a.b.c.d) {
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__const_with_fields.snap
··· 24 24 } 25 25 export const Mine$Mine = (a, b) => new Mine(a, b); 26 26 export const Mine$isMine = (value) => value instanceof Mine; 27 - export const Mine$Mine$0 = (value) => value[0]; 28 27 export const Mine$Mine$a = (value) => value.a; 29 - export const Mine$Mine$1 = (value) => value[1]; 28 + export const Mine$Mine$0 = (value) => value.a; 30 29 export const Mine$Mine$b = (value) => value.b; 30 + export const Mine$Mine$1 = (value) => value.b; 31 31 32 32 export const labels = /* @__PURE__ */ new Mine(1, 2); 33 33
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__constructors_get_their_own_jsdoc.snap
··· 27 27 } 28 28 export const Wibble$Wibble = (field) => new Wibble(field); 29 29 export const Wibble$isWibble = (value) => value instanceof Wibble; 30 - export const Wibble$Wibble$0 = (value) => value[0]; 31 30 export const Wibble$Wibble$field = (value) => value.field; 31 + export const Wibble$Wibble$0 = (value) => value.field; 32 32 33 33 /** 34 34 * Wobbling!! ··· 41 41 } 42 42 export const Wibble$Wobble = (field) => new Wobble(field); 43 43 export const Wibble$isWobble = (value) => value instanceof Wobble; 44 - export const Wibble$Wobble$0 = (value) => value[0]; 45 44 export const Wibble$Wobble$field = (value) => value.field; 45 + export const Wibble$Wobble$0 = (value) => value.field; 46 46 47 47 48 48 export const Wibble$field = (value) => value.field;
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__custom_type_with_named_fields.snap
··· 50 50 } 51 51 export const Cat$Cat = (name, cuteness) => new Cat(name, cuteness); 52 52 export const Cat$isCat = (value) => value instanceof Cat; 53 - export const Cat$Cat$0 = (value) => value[0]; 54 53 export const Cat$Cat$name = (value) => value.name; 55 - export const Cat$Cat$1 = (value) => value[1]; 54 + export const Cat$Cat$0 = (value) => value.name; 56 55 export const Cat$Cat$cuteness = (value) => value.cuteness; 56 + export const Cat$Cat$1 = (value) => value.cuteness; 57 57 58 58 export class Box extends $CustomType { 59 59 constructor(occupant) { ··· 63 63 } 64 64 export const Box$Box = (occupant) => new Box(occupant); 65 65 export const Box$isBox = (value) => value instanceof Box; 66 - export const Box$Box$0 = (value) => value[0]; 67 66 export const Box$Box$occupant = (value) => value.occupant; 67 + export const Box$Box$0 = (value) => value.occupant; 68 68 69 69 export function go() { 70 70 new Cat("Nubi", 1);
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__destructure_custom_type_with_mixed_fields_first_unlabelled.snap
··· 30 30 export const Cat$Cat = ($0, cuteness) => new Cat($0, cuteness); 31 31 export const Cat$isCat = (value) => value instanceof Cat; 32 32 export const Cat$Cat$0 = (value) => value[0]; 33 - export const Cat$Cat$1 = (value) => value[1]; 34 33 export const Cat$Cat$cuteness = (value) => value.cuteness; 34 + export const Cat$Cat$1 = (value) => value.cuteness; 35 35 36 36 export function go(cat) { 37 37 let x;
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__destructure_custom_type_with_named_fields.snap
··· 31 31 } 32 32 export const Cat$Cat = (name, cuteness) => new Cat(name, cuteness); 33 33 export const Cat$isCat = (value) => value instanceof Cat; 34 - export const Cat$Cat$0 = (value) => value[0]; 35 34 export const Cat$Cat$name = (value) => value.name; 36 - export const Cat$Cat$1 = (value) => value[1]; 35 + export const Cat$Cat$0 = (value) => value.name; 37 36 export const Cat$Cat$cuteness = (value) => value.cuteness; 37 + export const Cat$Cat$1 = (value) => value.cuteness; 38 38 39 39 export function go(cat) { 40 40 let x;
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__keyword_label_name.snap
··· 20 20 } 21 21 export const Thing$Thing = (in$, class$) => new Thing(in$, class$); 22 22 export const Thing$isThing = (value) => value instanceof Thing; 23 - export const Thing$Thing$0 = (value) => value[0]; 24 23 export const Thing$Thing$in = (value) => value.in; 25 - export const Thing$Thing$1 = (value) => value[1]; 24 + export const Thing$Thing$0 = (value) => value.in; 26 25 export const Thing$Thing$class = (value) => value.class; 26 + export const Thing$Thing$1 = (value) => value.class;
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__nested_pattern_with_labels.snap
··· 24 24 } 25 25 export const Box$Box = (a, b) => new Box(a, b); 26 26 export const Box$isBox = (value) => value instanceof Box; 27 - export const Box$Box$0 = (value) => value[0]; 28 27 export const Box$Box$a = (value) => value.a; 29 - export const Box$Box$1 = (value) => value[1]; 28 + export const Box$Box$0 = (value) => value.a; 30 29 export const Box$Box$b = (value) => value.b; 30 + export const Box$Box$1 = (value) => value.b; 31 31 32 32 export function go(x) { 33 33 let a = x.b.a;
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_access_in_guard_with_reserved_field_name.snap
··· 28 28 } 29 29 export const Thing$Thing = (constructor) => new Thing(constructor); 30 30 export const Thing$isThing = (value) => value instanceof Thing; 31 - export const Thing$Thing$0 = (value) => value[0]; 32 31 export const Thing$Thing$constructor = (value) => value.constructor$; 32 + export const Thing$Thing$0 = (value) => value.constructor$; 33 33 34 34 export function main() { 35 35 let a = new Thing(undefined);
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_access_in_pattern_with_reserved_field_name.snap
··· 30 30 } 31 31 export const Thing$Thing = (constructor) => new Thing(constructor); 32 32 export const Thing$isThing = (value) => value instanceof Thing; 33 - export const Thing$Thing$0 = (value) => value[0]; 34 33 export const Thing$Thing$constructor = (value) => value.constructor$; 34 + export const Thing$Thing$0 = (value) => value.constructor$; 35 35 36 36 export function main() { 37 37 let a = new Thing(undefined);
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_with_field_named_constructor.snap
··· 26 26 } 27 27 export const Thing$Thing = (constructor) => new Thing(constructor); 28 28 export const Thing$isThing = (value) => value instanceof Thing; 29 - export const Thing$Thing$0 = (value) => value[0]; 30 29 export const Thing$Thing$constructor = (value) => value.constructor$; 30 + export const Thing$Thing$0 = (value) => value.constructor$; 31 31 32 32 export function main() { 33 33 let a = new Thing(undefined);
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_with_field_named_then.snap
··· 26 26 } 27 27 export const Thing$Thing = (then$) => new Thing(then$); 28 28 export const Thing$isThing = (value) => value instanceof Thing; 29 - export const Thing$Thing$0 = (value) => value[0]; 30 29 export const Thing$Thing$then = (value) => value.then$; 30 + export const Thing$Thing$0 = (value) => value.then$; 31 31 32 32 export function main() { 33 33 let a = new Thing(undefined);
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__functions__immediately_invoked_function_expressions_include_statement_level.snap
··· 28 28 } 29 29 export const Wibble$Wibble = (a, b) => new Wibble(a, b); 30 30 export const Wibble$isWibble = (value) => value instanceof Wibble; 31 - export const Wibble$Wibble$0 = (value) => value[0]; 32 31 export const Wibble$Wibble$a = (value) => value.a; 33 - export const Wibble$Wibble$1 = (value) => value[1]; 32 + export const Wibble$Wibble$0 = (value) => value.a; 34 33 export const Wibble$Wibble$b = (value) => value.b; 34 + export const Wibble$Wibble$1 = (value) => value.b; 35 35 36 36 function identity(x) { 37 37 return x;
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__inlining__inlining_works_properly_with_record_updates.snap
··· 30 30 } 31 31 export const Wibble$Wibble = (a, b) => new Wibble(a, b); 32 32 export const Wibble$isWibble = (value) => value instanceof Wibble; 33 - export const Wibble$Wibble$0 = (value) => value[0]; 34 33 export const Wibble$Wibble$a = (value) => value.a; 35 - export const Wibble$Wibble$1 = (value) => value[1]; 34 + export const Wibble$Wibble$0 = (value) => value.a; 36 35 export const Wibble$Wibble$b = (value) => value.b; 36 + export const Wibble$Wibble$1 = (value) => value.b; 37 37 38 38 export function main() { 39 39 let w = new Wibble(1, 2);
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_constructor_is_escaped.snap
··· 20 20 } 21 21 export const Wibble$Wibble = (constructor) => new Wibble(constructor); 22 22 export const Wibble$isWibble = (value) => value instanceof Wibble; 23 - export const Wibble$Wibble$0 = (value) => value[0]; 24 23 export const Wibble$Wibble$constructor = (value) => value.constructor$; 24 + export const Wibble$Wibble$0 = (value) => value.constructor$;
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_prototype_is_escaped.snap
··· 20 20 } 21 21 export const Wibble$Wibble = (prototype) => new Wibble(prototype); 22 22 export const Wibble$isWibble = (value) => value instanceof Wibble; 23 - export const Wibble$Wibble$0 = (value) => value[0]; 24 23 export const Wibble$Wibble$prototype = (value) => value.prototype$; 24 + export const Wibble$Wibble$0 = (value) => value.prototype$;
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_then_is_escaped.snap
··· 20 20 } 21 21 export const Wibble$Wibble = (then$) => new Wibble(then$); 22 22 export const Wibble$isWibble = (value) => value instanceof Wibble; 23 - export const Wibble$Wibble$0 = (value) => value[0]; 24 23 export const Wibble$Wibble$then = (value) => value.then$; 24 + export const Wibble$Wibble$0 = (value) => value.then$;
+1 -1
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_x0.snap
··· 22 22 export const Wibble$Wibble = ($0, x0) => new Wibble($0, x0); 23 23 export const Wibble$isWibble = (value) => value instanceof Wibble; 24 24 export const Wibble$Wibble$0 = (value) => value[0]; 25 - export const Wibble$Wibble$1 = (value) => value[1]; 26 25 export const Wibble$Wibble$x0 = (value) => value.x0; 26 + export const Wibble$Wibble$1 = (value) => value.x0;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_variants.snap
··· 22 22 } 23 23 export const Person$Teacher = (name, title) => new Teacher(name, title); 24 24 export const Person$isTeacher = (value) => value instanceof Teacher; 25 - export const Person$Teacher$0 = (value) => value[0]; 26 25 export const Person$Teacher$name = (value) => value.name; 27 - export const Person$Teacher$1 = (value) => value[1]; 26 + export const Person$Teacher$0 = (value) => value.name; 28 27 export const Person$Teacher$title = (value) => value.title; 28 + export const Person$Teacher$1 = (value) => value.title; 29 29 30 30 export class Student extends $CustomType { 31 31 constructor(name, age) { ··· 36 36 } 37 37 export const Person$Student = (name, age) => new Student(name, age); 38 38 export const Person$isStudent = (value) => value instanceof Student; 39 - export const Person$Student$0 = (value) => value[0]; 40 39 export const Person$Student$name = (value) => value.name; 41 - export const Person$Student$1 = (value) => value[1]; 40 + export const Person$Student$0 = (value) => value.name; 42 41 export const Person$Student$age = (value) => value.age; 42 + export const Person$Student$1 = (value) => value.age; 43 43 44 44 45 45 export const Person$name = (value) => value.name;
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_variants_parameterised_types.snap
··· 25 25 export const Person$Teacher = (name, age, title) => 26 26 new Teacher(name, age, title); 27 27 export const Person$isTeacher = (value) => value instanceof Teacher; 28 - export const Person$Teacher$0 = (value) => value[0]; 29 28 export const Person$Teacher$name = (value) => value.name; 30 - export const Person$Teacher$1 = (value) => value[1]; 29 + export const Person$Teacher$0 = (value) => value.name; 31 30 export const Person$Teacher$age = (value) => value.age; 32 - export const Person$Teacher$2 = (value) => value[2]; 31 + export const Person$Teacher$1 = (value) => value.age; 33 32 export const Person$Teacher$title = (value) => value.title; 33 + export const Person$Teacher$2 = (value) => value.title; 34 34 35 35 export class Student extends $CustomType { 36 36 constructor(name, age) { ··· 41 41 } 42 42 export const Person$Student = (name, age) => new Student(name, age); 43 43 export const Person$isStudent = (value) => value instanceof Student; 44 - export const Person$Student$0 = (value) => value[0]; 45 44 export const Person$Student$name = (value) => value.name; 46 - export const Person$Student$1 = (value) => value[1]; 45 + export const Person$Student$0 = (value) => value.name; 47 46 export const Person$Student$age = (value) => value.age; 47 + export const Person$Student$1 = (value) => value.age; 48 48 49 49 50 50 export const Person$age = (value) => value.age;
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_variants_positions_other_than_first.snap
··· 25 25 export const Person$Teacher = (name, age, title) => 26 26 new Teacher(name, age, title); 27 27 export const Person$isTeacher = (value) => value instanceof Teacher; 28 - export const Person$Teacher$0 = (value) => value[0]; 29 28 export const Person$Teacher$name = (value) => value.name; 30 - export const Person$Teacher$1 = (value) => value[1]; 29 + export const Person$Teacher$0 = (value) => value.name; 31 30 export const Person$Teacher$age = (value) => value.age; 32 - export const Person$Teacher$2 = (value) => value[2]; 31 + export const Person$Teacher$1 = (value) => value.age; 33 32 export const Person$Teacher$title = (value) => value.title; 33 + export const Person$Teacher$2 = (value) => value.title; 34 34 35 35 export class Student extends $CustomType { 36 36 constructor(name, age) { ··· 41 41 } 42 42 export const Person$Student = (name, age) => new Student(name, age); 43 43 export const Person$isStudent = (value) => value instanceof Student; 44 - export const Person$Student$0 = (value) => value[0]; 45 44 export const Person$Student$name = (value) => value.name; 46 - export const Person$Student$1 = (value) => value[1]; 45 + export const Person$Student$0 = (value) => value.name; 47 46 export const Person$Student$age = (value) => value.age; 47 + export const Person$Student$1 = (value) => value.age; 48 48 49 49 50 50 export const Person$age = (value) => value.age;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_with_first_position_different_types.snap
··· 22 22 } 23 23 export const Person$Teacher = (name, age) => new Teacher(name, age); 24 24 export const Person$isTeacher = (value) => value instanceof Teacher; 25 - export const Person$Teacher$0 = (value) => value[0]; 26 25 export const Person$Teacher$name = (value) => value.name; 27 - export const Person$Teacher$1 = (value) => value[1]; 26 + export const Person$Teacher$0 = (value) => value.name; 28 27 export const Person$Teacher$age = (value) => value.age; 28 + export const Person$Teacher$1 = (value) => value.age; 29 29 30 30 export class Student extends $CustomType { 31 31 constructor(name, age) { ··· 36 36 } 37 37 export const Person$Student = (name, age) => new Student(name, age); 38 38 export const Person$isStudent = (value) => value instanceof Student; 39 - export const Person$Student$0 = (value) => value[0]; 40 39 export const Person$Student$name = (value) => value.name; 41 - export const Person$Student$1 = (value) => value[1]; 40 + export const Person$Student$0 = (value) => value.name; 42 41 export const Person$Student$age = (value) => value.age; 42 + export const Person$Student$1 = (value) => value.age; 43 43 44 44 45 45 export const Person$age = (value) => value.age;
+2 -2
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessors.snap
··· 21 21 } 22 22 export const Person$Person = (name, age) => new Person(name, age); 23 23 export const Person$isPerson = (value) => value instanceof Person; 24 - export const Person$Person$0 = (value) => value[0]; 25 24 export const Person$Person$name = (value) => value.name; 26 - export const Person$Person$1 = (value) => value[1]; 25 + export const Person$Person$0 = (value) => value.name; 27 26 export const Person$Person$age = (value) => value.age; 27 + export const Person$Person$1 = (value) => value.age; 28 28 29 29 export function get_age(person) { 30 30 return person.age;