Skip to content

Commit

Permalink
improve scope computation of member access expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 committed Apr 15, 2024
1 parent 4a2681e commit 8962e89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/schema/src/language-server/zmodel-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ export class ZModelScopeProvider extends DefaultScopeProvider {
return EMPTY_SCOPE;
})
.when(isMemberAccessExpr, (operand) => {
// operand is a member access, it must be resolved to a
// operand is a member access, it must be resolved to a non-array data model type
const ref = operand.member.ref;
if (isDataModelField(ref)) {
if (isDataModelField(ref) && !ref.type.array) {
const targetModel = ref.type.reference?.ref;
return this.createScopeForModel(targetModel, globalScope);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tests/regression/issue-756.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ describe('Regression: issue 756', () => {
}
`
)
).toContain('expression cannot be resolved');
).toContain(`Could not resolve reference to DataModelField named 'authorId'.`);
});
});

0 comments on commit 8962e89

Please sign in to comment.