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

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.cjs CHANGED
@@ -5386,7 +5386,7 @@ function getFunctionExpressionContext(funcDecl) {
5386
5386
  }
5387
5387
  __name(getFunctionExpressionContext, "getFunctionExpressionContext");
5388
5388
  function isCheckInvocation(node) {
5389
- return isInvocationExpr(node) && node.function.ref?.name === "check" && isFromStdlib(node.function.ref);
5389
+ return isInvocationExpr(node) && node.function.ref?.name === "check";
5390
5390
  }
5391
5391
  __name(isCheckInvocation, "isCheckInvocation");
5392
5392
  function resolveTransitiveImports(documents, model) {
@@ -6573,23 +6573,25 @@ var ExpressionValidator = class {
6573
6573
  "Any"
6574
6574
  ];
6575
6575
  }
6576
- if (typeof expr.left.$resolvedType?.decl !== "string" || !supportedShapes.includes(expr.left.$resolvedType.decl)) {
6576
+ const leftResolvedDecl = expr.left.$resolvedType?.decl;
6577
+ const rightResolvedDecl = expr.right.$resolvedType?.decl;
6578
+ if (leftResolvedDecl && (typeof leftResolvedDecl !== "string" || !supportedShapes.includes(leftResolvedDecl))) {
6577
6579
  accept("error", `invalid operand type for "${expr.operator}" operator`, {
6578
6580
  node: expr.left
6579
6581
  });
6580
6582
  return;
6581
6583
  }
6582
- if (typeof expr.right.$resolvedType?.decl !== "string" || !supportedShapes.includes(expr.right.$resolvedType.decl)) {
6584
+ if (rightResolvedDecl && (typeof rightResolvedDecl !== "string" || !supportedShapes.includes(rightResolvedDecl))) {
6583
6585
  accept("error", `invalid operand type for "${expr.operator}" operator`, {
6584
6586
  node: expr.right
6585
6587
  });
6586
6588
  return;
6587
6589
  }
6588
- if (expr.left.$resolvedType.decl === "DateTime" && expr.right.$resolvedType.decl !== "DateTime") {
6590
+ if (leftResolvedDecl === "DateTime" && rightResolvedDecl && rightResolvedDecl !== "DateTime") {
6589
6591
  accept("error", "incompatible operand types", {
6590
6592
  node: expr
6591
6593
  });
6592
- } else if (expr.right.$resolvedType.decl === "DateTime" && expr.left.$resolvedType.decl !== "DateTime") {
6594
+ } else if (rightResolvedDecl === "DateTime" && leftResolvedDecl && leftResolvedDecl !== "DateTime") {
6593
6595
  accept("error", "incompatible operand types", {
6594
6596
  node: expr
6595
6597
  });
@@ -6825,6 +6827,7 @@ var FunctionInvocationValidator = class {
6825
6827
  }
6826
6828
  return true;
6827
6829
  }
6830
+ // TODO: move this to policy plugin
6828
6831
  _checkCheck(expr, accept) {
6829
6832
  let valid = true;
6830
6833
  const fieldArg = expr.args[0].value;