Skip to content

Adding a struct to an existing struct incorrectly overwrites existing properties. Instead it should recursively add them. #88

Description

@harrisont

Repro:

.StructA =
[
  .ArrayOfStrings     = { 'String1', 'String2' }
  .String             = 'String'
]

.StructB =
[
  .ArrayOfStrings     = { 'String3' }
  .String             = '!'
]

.StructC = .StructA
         + .StructB

Actual .C result:

[
    .ArrayOfStrings = {
        'String3'
    }
    .String = '!'
]

Expected .C result:

[
    .ArrayOfStrings = {
        'String1',
        'String2',
        'String3'
    }
    .String = 'String!'
]

FASTBuild docs for adding structs

Problematic test case:

it('should work on adding a struct to a struct', () => {
const input = `
.Struct1 = [
.A=0
.B=2
]
.Struct2 = [
.A=1
.C=3
]
.MyVar = .Struct1 + .Struct2
`;
const struct1ADefinition: VariableDefinition = { id: 1, range: createRange(2, 20, 22), name: 'A' };
const struct1BDefinition: VariableDefinition = { id: 2, range: createRange(3, 20, 22), name: 'B' };
const struct1 = Struct.from(Object.entries({
A: new StructMember(0, [struct1ADefinition]),
B: new StructMember(2, [struct1BDefinition]),
}));
const struct2ADefinition: VariableDefinition = { id: 4, range: createRange(6, 20, 22), name: 'A' };
const struct2CDefinition: VariableDefinition = { id: 5, range: createRange(7, 20, 22), name: 'C' };
const struct2 = Struct.from(Object.entries({
A: new StructMember(1, [struct2ADefinition]),
C: new StructMember(3, [struct2CDefinition]),
}));
assertEvaluatedVariablesValueEqual(input, [
0,
2,
struct1,
1,
3,
struct2,
struct1,
struct2,
Struct.from(Object.entries({
A: new StructMember(1, [struct2ADefinition]),
B: new StructMember(2, [struct1BDefinition]),
C: new StructMember(3, [struct2CDefinition]),
}))
]);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions