Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,31 @@ function assignableToAttributeParam(arg: AttributeArg, param: AttributeParam, at

let dstType = param.type.type;
let dstIsArray = param.type.array;

if (dstType === 'ContextType') {
// ContextType is inferred from the attribute's container's type
if (isDataModelField(attr.$container)) {
dstIsArray = attr.$container.type.array;
}
}

const dstRef = param.type.reference;

if (dstType === 'Any' && !dstIsArray) {
return true;
}

if (argResolvedType.decl === 'Any') {
// arg is any type
if (!argResolvedType.array) {
// if it's not an array, it's assignable to any type
return true;
} else {
// otherwise it's assignable to any array type
return argResolvedType.array === dstIsArray;
}
}

// destination is field reference or transitive field reference, check if
// argument is reference or array or reference
if (dstType === 'FieldReference' || dstType === 'TransitiveFieldReference') {
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/tests/regression/issue-947.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { loadModel } from '@zenstackhq/testtools';

describe('Regression: issue 947', () => {
it('regression', async () => {
await loadModel(
`
model Test {
id String @id
props TestEnum[] @default([])
}

enum TestEnum {
A
B
}
`
);
});
});