@zenstackhq/language 3.0.0-beta.4 → 3.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5354,7 +5354,7 @@ function getFunctionExpressionContext(funcDecl) {
5354
5354
  }
5355
5355
  __name(getFunctionExpressionContext, "getFunctionExpressionContext");
5356
5356
  function isCheckInvocation(node) {
5357
- return isInvocationExpr(node) && node.function.ref?.name === "check" && isFromStdlib(node.function.ref);
5357
+ return isInvocationExpr(node) && node.function.ref?.name === "check";
5358
5358
  }
5359
5359
  __name(isCheckInvocation, "isCheckInvocation");
5360
5360
  function resolveTransitiveImports(documents, model) {
@@ -6541,23 +6541,25 @@ var ExpressionValidator = class {
6541
6541
  "Any"
6542
6542
  ];
6543
6543
  }
6544
- if (typeof expr.left.$resolvedType?.decl !== "string" || !supportedShapes.includes(expr.left.$resolvedType.decl)) {
6544
+ const leftResolvedDecl = expr.left.$resolvedType?.decl;
6545
+ const rightResolvedDecl = expr.right.$resolvedType?.decl;
6546
+ if (leftResolvedDecl && (typeof leftResolvedDecl !== "string" || !supportedShapes.includes(leftResolvedDecl))) {
6545
6547
  accept("error", `invalid operand type for "${expr.operator}" operator`, {
6546
6548
  node: expr.left
6547
6549
  });
6548
6550
  return;
6549
6551
  }
6550
- if (typeof expr.right.$resolvedType?.decl !== "string" || !supportedShapes.includes(expr.right.$resolvedType.decl)) {
6552
+ if (rightResolvedDecl && (typeof rightResolvedDecl !== "string" || !supportedShapes.includes(rightResolvedDecl))) {
6551
6553
  accept("error", `invalid operand type for "${expr.operator}" operator`, {
6552
6554
  node: expr.right
6553
6555
  });
6554
6556
  return;
6555
6557
  }
6556
- if (expr.left.$resolvedType.decl === "DateTime" && expr.right.$resolvedType.decl !== "DateTime") {
6558
+ if (leftResolvedDecl === "DateTime" && rightResolvedDecl && rightResolvedDecl !== "DateTime") {
6557
6559
  accept("error", "incompatible operand types", {
6558
6560
  node: expr
6559
6561
  });
6560
- } else if (expr.right.$resolvedType.decl === "DateTime" && expr.left.$resolvedType.decl !== "DateTime") {
6562
+ } else if (rightResolvedDecl === "DateTime" && leftResolvedDecl && leftResolvedDecl !== "DateTime") {
6561
6563
  accept("error", "incompatible operand types", {
6562
6564
  node: expr
6563
6565
  });
@@ -6793,6 +6795,7 @@ var FunctionInvocationValidator = class {
6793
6795
  }
6794
6796
  return true;
6795
6797
  }
6798
+ // TODO: move this to policy plugin
6796
6799
  _checkCheck(expr, accept) {
6797
6800
  let valid = true;
6798
6801
  const fieldArg = expr.args[0].value;