Skip to content

Mixing defaults, references inside a record #2188

Answered by jneem
eloualiche asked this question in Q&A
Discussion options

You must be logged in to vote

I can explain the merge behavior that you're seeing: when you merge two records that have the same field, if one of the records has a higher merge priority on that field then it "wins", and if they have the same merge priority then the values of the fields are merged recursively. For example,

{
  subfield1 | default = { foo = 1 },
  subfield2 = { foo | default = 1 },
}
& {
  subfield1 = { bar = 1 },
  subfield2 = { bar = 1 },
}

outputs

{
  "subfield1": {
    "bar": 1
  },
  "subfield2": {
    "bar": 1,
    "foo": 1
  }
}

The "subfield1" values aren't merged recursively because the "default" one just loses outright.

My other feedback is that for fields that are themselves records, it's of…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@eloualiche
Comment options

@jneem
Comment options

jneem Mar 11, 2025
Collaborator

@eloualiche
Comment options

@yannham
Comment options

@eloualiche
Comment options

Answer selected by eloualiche
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants