@rsconcept/domain 1.4.5 → 1.4.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/{analyzer-BIVXNtT6.d.ts → analyzer-54lGGg13.d.ts} +2 -2
- package/dist/{ast-annotations-Dfz-KtUp.d.ts → ast-annotations-C0eMySxt.d.ts} +2 -2
- package/dist/{calculator-KRU6RIzZ.d.ts → calculator-BQnE2gws.d.ts} +2 -2
- package/dist/{error-CpOz9MFT.d.ts → error-CxIs0A7Y.d.ts} +4 -1
- package/dist/index.d.ts +4 -4
- package/dist/library/rsengine.d.ts +1 -1
- package/dist/library/rsform-api.d.ts +1 -1
- package/dist/library/rsform.d.ts +1 -1
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/error.d.ts +1 -1
- package/dist/rslang/error.js +3 -0
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/evaluator.d.ts +1 -1
- package/dist/rslang/index.d.ts +4 -4
- package/dist/rslang/parser/syntax-errors.d.ts +1 -1
- package/dist/rslang/parser/syntax-errors.js +123 -9
- package/dist/rslang/parser/syntax-errors.js.map +1 -1
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +3 -1
- package/dist/rslang/semantic/type-auditor.js +44 -13
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +1 -1
- package/package.json +5 -5
- package/src/rslang/error.ts +3 -0
- package/src/rslang/parser/parser.test.ts +5 -1
- package/src/rslang/parser/syntax-errors.ts +194 -9
- package/src/rslang/semantic/type-auditor.test.ts +7 -4
- package/src/rslang/semantic/type-auditor.ts +55 -16
|
@@ -351,6 +351,9 @@ export class TypeAuditor {
|
|
|
351
351
|
if (!type) {
|
|
352
352
|
return this.onError(RSErrorCode.globalNotTyped, node, [alias]);
|
|
353
353
|
}
|
|
354
|
+
if (type.typeID === TypeID.function || type.typeID === TypeID.predicate) {
|
|
355
|
+
return this.onError(RSErrorCode.globalFuncWithoutArgs, node, [alias]);
|
|
356
|
+
}
|
|
354
357
|
return type;
|
|
355
358
|
}
|
|
356
359
|
|
|
@@ -744,7 +747,12 @@ export class TypeAuditor {
|
|
|
744
747
|
const indices = getNodeIndices(node);
|
|
745
748
|
const tupleParam = indices.length === node.children.length - 1;
|
|
746
749
|
if (!tupleParam && node.children.length > 2) {
|
|
747
|
-
|
|
750
|
+
const extraParam = node.children[indices.length];
|
|
751
|
+
return this.onError(RSErrorCode.invalidFilterArity, extraParam ?? node, [
|
|
752
|
+
String(indices.length),
|
|
753
|
+
String(node.children.length - 1),
|
|
754
|
+
operator
|
|
755
|
+
]);
|
|
748
756
|
}
|
|
749
757
|
|
|
750
758
|
const argument = this.childTypification(node, node.children.length - 1);
|
|
@@ -757,10 +765,12 @@ export class TypeAuditor {
|
|
|
757
765
|
) {
|
|
758
766
|
return EmptySetT;
|
|
759
767
|
}
|
|
768
|
+
const expectedArgument = this.expectedFilterArgumentLabel(indices);
|
|
760
769
|
if (argument.typeID !== TypeID.collection || argument.base.typeID !== TypeID.tuple) {
|
|
761
770
|
return this.onError(RSErrorCode.invalidFilterArgumentType, node.children[node.children.length - 1], [
|
|
762
|
-
|
|
763
|
-
labelType(argument)
|
|
771
|
+
operator,
|
|
772
|
+
labelType(argument),
|
|
773
|
+
expectedArgument
|
|
764
774
|
]);
|
|
765
775
|
}
|
|
766
776
|
|
|
@@ -769,9 +779,11 @@ export class TypeAuditor {
|
|
|
769
779
|
for (const index of indices) {
|
|
770
780
|
const newBase = component(argBase, index);
|
|
771
781
|
if (newBase === null) {
|
|
772
|
-
return this.onError(RSErrorCode.
|
|
773
|
-
|
|
774
|
-
labelType(argument)
|
|
782
|
+
return this.onError(RSErrorCode.invalidFilterIndex, node.children[node.children.length - 1], [
|
|
783
|
+
operator,
|
|
784
|
+
labelType(argument),
|
|
785
|
+
String(index),
|
|
786
|
+
String(argBase.factors.length)
|
|
775
787
|
]);
|
|
776
788
|
}
|
|
777
789
|
bases.push(newBase);
|
|
@@ -783,12 +795,9 @@ export class TypeAuditor {
|
|
|
783
795
|
if (param === null) {
|
|
784
796
|
return null;
|
|
785
797
|
}
|
|
798
|
+
const expectedParam = bool(bases[child]);
|
|
786
799
|
if (param.typeID !== TypeID.collection || !checkCompatibility(bases[child], debool(param))) {
|
|
787
|
-
return this.
|
|
788
|
-
labelType(param),
|
|
789
|
-
labelType(bool(bases[child])),
|
|
790
|
-
operator
|
|
791
|
-
]);
|
|
800
|
+
return this.reportFilterParameterError(node, child, param, expectedParam, operator);
|
|
792
801
|
}
|
|
793
802
|
}
|
|
794
803
|
} else {
|
|
@@ -799,16 +808,46 @@ export class TypeAuditor {
|
|
|
799
808
|
const paramType = param;
|
|
800
809
|
const expected = bool(tuple(bases));
|
|
801
810
|
if (paramType.typeID !== TypeID.collection || !checkCompatibility(expected, paramType)) {
|
|
802
|
-
return this.
|
|
803
|
-
labelType(paramType),
|
|
804
|
-
labelType(expected),
|
|
805
|
-
operator
|
|
806
|
-
]);
|
|
811
|
+
return this.reportFilterParameterError(node, 0, paramType, expected, operator);
|
|
807
812
|
}
|
|
808
813
|
}
|
|
809
814
|
return argument;
|
|
810
815
|
}
|
|
811
816
|
|
|
817
|
+
private expectedFilterArgumentLabel(indices: number[]): string {
|
|
818
|
+
const maxIndex = Math.max(...indices, 0);
|
|
819
|
+
if (maxIndex <= 1) {
|
|
820
|
+
return labelType(bool({ typeID: TypeID.anyTypification }));
|
|
821
|
+
}
|
|
822
|
+
const factors: Typification[] = [];
|
|
823
|
+
for (let index = 1; index <= maxIndex; index++) {
|
|
824
|
+
factors.push({ typeID: TypeID.anyTypification });
|
|
825
|
+
}
|
|
826
|
+
return labelType(bool(tuple(factors)));
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
private reportFilterParameterError(
|
|
830
|
+
node: AstNode,
|
|
831
|
+
childIndex: number,
|
|
832
|
+
param: Typification,
|
|
833
|
+
expected: Typification,
|
|
834
|
+
operator: string
|
|
835
|
+
): null {
|
|
836
|
+
const wrapped = bool(param);
|
|
837
|
+
if (checkEquality(wrapped, expected) || checkCompatibility(wrapped, expected)) {
|
|
838
|
+
return this.onError(RSErrorCode.invalidFilterBooleanEchelon, node.children[childIndex], [
|
|
839
|
+
operator,
|
|
840
|
+
labelType(param),
|
|
841
|
+
labelType(expected)
|
|
842
|
+
]);
|
|
843
|
+
}
|
|
844
|
+
return this.onError(RSErrorCode.invalidFilterParameterType, node.children[childIndex], [
|
|
845
|
+
labelType(param),
|
|
846
|
+
labelType(expected),
|
|
847
|
+
operator
|
|
848
|
+
]);
|
|
849
|
+
}
|
|
850
|
+
|
|
812
851
|
private visitReduce(node: AstNode): ExpressionType | null {
|
|
813
852
|
const argument = this.childTypification(node, 0);
|
|
814
853
|
if (argument === null) {
|