E3020

E3020#

Unexpected = in struct expression. The correct syntax for struct expression is { field: expression }.

Erroneous example#

pub(all) struct S {
  a : Int
  b : Int
}

fn replace_a(s : S) -> S {
  let ss = { ..s, a = 1 } // Error: Unexpected `=` in struct expression.
  ss
}

test {
  ignore(replace_a({ a: 0, b: 2 }))
}

Suggestion#

Change the struct expression to use the correct syntax:

///|
pub(all) struct  {
   : 
   : 
}

///|
fn ( : ) ->  {
  let  = { .., : 1 }
  
}

///|
test {
  (({ : 0, : 2 })., ="1")
}