@rsconcept/domain 1.4.2 → 1.4.4
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-BliNe3pV.d.ts → analyzer-ZYeBT1ty.d.ts} +2 -2
- package/dist/{ast-annotations-GOkbNN8F.d.ts → ast-annotations-DiD1gWzO.d.ts} +2 -2
- package/dist/{calculator-DFevxZyV.d.ts → calculator-ClGbZzu9.d.ts} +2 -2
- package/dist/{error-deey7EiC.d.ts → error-Db9thkr6.d.ts} +3 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/library/rsengine.d.ts +1 -1
- package/dist/library/rsengine.js +2 -2
- package/dist/library/rsform-api.d.ts +1 -1
- package/dist/library/rsform.d.ts +1 -1
- package/dist/library/rsmodel-api.js +1 -1
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/error.d.ts +1 -1
- package/dist/rslang/error.js +2 -0
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/calculator.js +1 -1
- package/dist/rslang/eval/evaluator.d.ts +1 -1
- package/dist/rslang/eval/evaluator.js +7 -2
- package/dist/rslang/eval/evaluator.js.map +1 -1
- package/dist/rslang/eval/value-api.js +1 -1
- package/dist/rslang/eval/value.js +1 -1
- package/dist/rslang/index.d.ts +4 -4
- package/dist/rslang/index.js +1 -1
- package/dist/rslang/labels.js +1 -0
- package/dist/rslang/labels.js.map +1 -1
- package/dist/rslang/parser/syntax-errors.d.ts +1 -1
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +2 -1
- package/dist/rslang/semantic/type-auditor.js +73 -20
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +1 -1
- package/dist/{value-ybFBRuz6.js → value-COprb2Je.js} +2 -2
- package/dist/{value-ybFBRuz6.js.map → value-COprb2Je.js.map} +1 -1
- package/package.json +1 -1
- package/src/rslang/error.ts +2 -0
- package/src/rslang/eval/evaluator.test.ts +2 -2
- package/src/rslang/eval/evaluator.ts +2 -1
- package/src/rslang/labels.ts +1 -0
- package/src/rslang/semantic/type-auditor.test.ts +22 -16
- package/src/rslang/semantic/type-auditor.ts +66 -21
package/src/rslang/labels.ts
CHANGED
|
@@ -38,6 +38,7 @@ const labelTokenRecord: Partial<Record<TokenID, string>> = {
|
|
|
38
38
|
[TokenID.NT_DECLARATIVE_EXPR]: 'D{}',
|
|
39
39
|
[TokenID.NT_IMPERATIVE_EXPR]: 'I{}',
|
|
40
40
|
[TokenID.NT_RECURSIVE_FULL]: 'R{}',
|
|
41
|
+
[TokenID.NT_RECURSIVE_SHORT]: 'R{}',
|
|
41
42
|
[TokenID.BIGPR]: 'Pr1()',
|
|
42
43
|
[TokenID.SMALLPR]: 'pr1()',
|
|
43
44
|
[TokenID.FILTER]: 'Fi1[]()',
|
|
@@ -170,14 +170,14 @@ const errorData = [
|
|
|
170
170
|
['card(S3)', { code: RSErrorCode.invalidCard, from: 5, to: 7, params: ['C1'] }],
|
|
171
171
|
['card(1)', { code: RSErrorCode.invalidCard, from: 5, to: 6, params: ['Z'] }],
|
|
172
172
|
['card((1,2))', { code: RSErrorCode.invalidCard, from: 5, to: 10, params: ['Z×Z'] }],
|
|
173
|
-
['debool(X1)+1', { code: RSErrorCode.arithmeticNotSupported, from: 0, to: 10, params: ['X1'] }],
|
|
174
|
-
['1+debool(X1)', { code: RSErrorCode.arithmeticNotSupported, from: 2, to: 12, params: ['X1'] }],
|
|
173
|
+
['debool(X1)+1', { code: RSErrorCode.arithmeticNotSupported, from: 0, to: 10, params: ['X1', '+'] }],
|
|
174
|
+
['1+debool(X1)', { code: RSErrorCode.arithmeticNotSupported, from: 2, to: 12, params: ['X1', '+'] }],
|
|
175
175
|
// Logical
|
|
176
176
|
['debool(X1)<1', { code: RSErrorCode.orderingNotSupported, from: 0, to: 10, params: ['X1', '<'] }],
|
|
177
177
|
['1<debool(X1)', { code: RSErrorCode.orderingNotSupported, from: 2, to: 12, params: ['X1', '<'] }],
|
|
178
|
-
['debool(X1)=1', { code: RSErrorCode.typesNotCompatible, from: 0, to: 12, params: ['X1', 'Z'] }],
|
|
179
|
-
['1=debool(X1)', { code: RSErrorCode.typesNotCompatible, from: 0, to: 12, params: ['Z', 'X1'] }],
|
|
180
|
-
['S1=S2', { code: RSErrorCode.typesNotCompatible, from: 0, to: 5, params: ['ℬ(X1×X1)', 'ℬℬ(X1)'] }],
|
|
178
|
+
['debool(X1)=1', { code: RSErrorCode.typesNotCompatible, from: 0, to: 12, params: ['X1', 'Z', '='] }],
|
|
179
|
+
['1=debool(X1)', { code: RSErrorCode.typesNotCompatible, from: 0, to: 12, params: ['Z', 'X1', '='] }],
|
|
180
|
+
['S1=S2', { code: RSErrorCode.typesNotCompatible, from: 0, to: 5, params: ['ℬ(X1×X1)', 'ℬℬ(X1)', '='] }],
|
|
181
181
|
['∀a,a∈X1 a=a', { code: RSErrorCode.localShadowing, from: 3, to: 4, params: ['a'] }],
|
|
182
182
|
['∀(a,a)∈S1 a=a', { code: RSErrorCode.localShadowing, from: 4, to: 5, params: ['a'] }],
|
|
183
183
|
['∀(a,b)∈X1 a=b', { code: RSErrorCode.invalidCortegeDeclare, from: 2, to: 3 }],
|
|
@@ -190,9 +190,9 @@ const errorData = [
|
|
|
190
190
|
['(1,2)∈Z', { code: RSErrorCode.invalidElementPredicate, from: 0, to: 7, params: ['Z×Z', '∈', 'ℬ(Z)'] }],
|
|
191
191
|
['{1}∈Z', { code: RSErrorCode.invalidElementPredicate, from: 0, to: 5, params: ['ℬ(Z)', '∈', 'ℬ(Z)'] }],
|
|
192
192
|
['{1}∉Z', { code: RSErrorCode.invalidElementPredicate, from: 0, to: 5, params: ['ℬ(Z)', '∉', 'ℬ(Z)'] }],
|
|
193
|
-
['X1⊆S2', { code: RSErrorCode.typesNotEqual, from: 0, to: 5, params: ['ℬ(X1)', 'ℬℬ(X1)'] }],
|
|
194
|
-
['X1⊄S2', { code: RSErrorCode.typesNotEqual, from: 0, to: 5, params: ['ℬ(X1)', 'ℬℬ(X1)'] }],
|
|
195
|
-
['X1⊂S2', { code: RSErrorCode.typesNotEqual, from: 0, to: 5, params: ['ℬ(X1)', 'ℬℬ(X1)'] }],
|
|
193
|
+
['X1⊆S2', { code: RSErrorCode.typesNotEqual, from: 0, to: 5, params: ['ℬ(X1)', 'ℬℬ(X1)', '⊆'] }],
|
|
194
|
+
['X1⊄S2', { code: RSErrorCode.typesNotEqual, from: 0, to: 5, params: ['ℬ(X1)', 'ℬℬ(X1)', '⊄'] }],
|
|
195
|
+
['X1⊂S2', { code: RSErrorCode.typesNotEqual, from: 0, to: 5, params: ['ℬ(X1)', 'ℬℬ(X1)', '⊂'] }],
|
|
196
196
|
// Constructors
|
|
197
197
|
['ℬ(S3)', { code: RSErrorCode.invalidBoolean, from: 2, to: 4, params: ['C1'] }],
|
|
198
198
|
['ℬ((1,2))', { code: RSErrorCode.invalidBoolean, from: 2, to: 7, params: ['Z×Z'] }],
|
|
@@ -202,15 +202,15 @@ const errorData = [
|
|
|
202
202
|
['{1, X1}', { code: RSErrorCode.invalidEnumeration, from: 4, to: 6, params: ['Z', 'ℬ(X1)'] }],
|
|
203
203
|
['{X1, 1}', { code: RSErrorCode.invalidEnumeration, from: 5, to: 6, params: ['ℬ(X1)', 'Z'] }],
|
|
204
204
|
['{(1,2), (X1,X1)}', { code: RSErrorCode.invalidEnumeration, from: 8, to: 15, params: ['Z×Z', 'ℬ(X1)×ℬ(X1)'] }],
|
|
205
|
-
['R{a := S1 | {a}}', { code: RSErrorCode.typesNotEqual, from: 12, to: 15, params: ['ℬℬ(X1×X1)', 'ℬ(X1×X1)'] }],
|
|
205
|
+
['R{a := S1 | {a}}', { code: RSErrorCode.typesNotEqual, from: 12, to: 15, params: ['ℬℬ(X1×X1)', 'ℬ(X1×X1)', 'R{}'] }],
|
|
206
206
|
[
|
|
207
207
|
'I{(a, b) | a:∈X1; b:={a}; a≠b}',
|
|
208
|
-
{ code: RSErrorCode.typesNotCompatible, from: 26, to: 29, params: ['X1', 'ℬ(X1)'] }
|
|
208
|
+
{ code: RSErrorCode.typesNotCompatible, from: 26, to: 29, params: ['X1', 'ℬ(X1)', '≠'] }
|
|
209
209
|
],
|
|
210
210
|
// Set operations
|
|
211
211
|
['X1 ∪ ∅', { code: RSErrorCode.invalidEmptySetUsage, from: 5, to: 6 }],
|
|
212
|
-
['X1 ∪ S1', { code: RSErrorCode.typesNotEqual, from: 0, to: 7, params: ['ℬ(X1)', 'ℬ(X1×X1)'] }],
|
|
213
|
-
['S1 ∪ X1', { code: RSErrorCode.typesNotEqual, from: 0, to: 7, params: ['ℬ(X1×X1)', 'ℬ(X1)'] }],
|
|
212
|
+
['X1 ∪ S1', { code: RSErrorCode.typesNotEqual, from: 0, to: 7, params: ['ℬ(X1)', 'ℬ(X1×X1)', '∪'] }],
|
|
213
|
+
['S1 ∪ X1', { code: RSErrorCode.typesNotEqual, from: 0, to: 7, params: ['ℬ(X1×X1)', 'ℬ(X1)', '∪'] }],
|
|
214
214
|
['Pr1(X1)', { code: RSErrorCode.invalidProjectionSet, from: 4, to: 6, params: ['Pr1', 'ℬ(X1)'] }],
|
|
215
215
|
['Pr3(S1)', { code: RSErrorCode.invalidProjectionSet, from: 4, to: 6, params: ['Pr3', 'ℬ(X1×X1)'] }],
|
|
216
216
|
['Pr1,3(S1)', { code: RSErrorCode.invalidProjectionSet, from: 6, to: 8, params: ['Pr1,3', 'ℬ(X1×X1)'] }],
|
|
@@ -219,11 +219,17 @@ const errorData = [
|
|
|
219
219
|
['pr1(debool(X1))', { code: RSErrorCode.invalidProjectionTuple, from: 4, to: 14, params: ['pr1', 'X1'] }],
|
|
220
220
|
['pr3(debool(S1))', { code: RSErrorCode.invalidProjectionTuple, from: 4, to: 14, params: ['pr3', 'X1×X1'] }],
|
|
221
221
|
['Fi1[X1](ℬ(X1))', { code: RSErrorCode.invalidFilterArgumentType, from: 8, to: 13, params: ['Fi1', 'ℬℬ(X1)'] }],
|
|
222
|
-
['Fi1[1](S1)', { code: RSErrorCode.
|
|
223
|
-
[
|
|
222
|
+
['Fi1[1](S1)', { code: RSErrorCode.invalidFilterParameterType, from: 4, to: 5, params: ['Z', 'ℬ(X1)', 'Fi1'] }],
|
|
223
|
+
[
|
|
224
|
+
'Fi1[X1](ℬ(X1)×X1)',
|
|
225
|
+
{ code: RSErrorCode.invalidFilterParameterType, from: 4, to: 6, params: ['ℬ(X1)', 'ℬℬ(X1)', 'Fi1'] }
|
|
226
|
+
],
|
|
224
227
|
['Fi3[X1](S1)', { code: RSErrorCode.invalidFilterArgumentType, from: 8, to: 10, params: ['Fi3', 'ℬ(X1×X1)'] }],
|
|
225
228
|
['Fi1[X1,X1](S1)', { code: RSErrorCode.invalidFilterArity, from: 0, to: 14 }],
|
|
226
|
-
[
|
|
229
|
+
[
|
|
230
|
+
'Fi1,2[X1](S1)',
|
|
231
|
+
{ code: RSErrorCode.invalidFilterParameterType, from: 6, to: 8, params: ['ℬ(X1)', 'ℬ(X1×X1)', 'Fi1,2'] }
|
|
232
|
+
],
|
|
227
233
|
['red(X1)', { code: RSErrorCode.invalidReduce, from: 4, to: 6, params: ['ℬ(X1)'] }],
|
|
228
234
|
['debool(S3)', { code: RSErrorCode.invalidDebool, from: 7, to: 9, params: ['C1'] }],
|
|
229
235
|
// Locals
|
|
@@ -236,7 +242,7 @@ const errorData = [
|
|
|
236
242
|
// Logic vs setexpr discrimination
|
|
237
243
|
['D{α∈X1|F1[X1,X1]}', { code: RSErrorCode.expectedLogic, from: 7, to: 16, params: ['ℬ(X1)'] }],
|
|
238
244
|
['F1[1=1,X1]', { code: RSErrorCode.expectedSetexpr, from: 3, to: 6, params: ['Logic'] }],
|
|
239
|
-
['∀a∈(1=1) a=a', { code: RSErrorCode.
|
|
245
|
+
['∀a∈(1=1) a=a', { code: RSErrorCode.invalidQuantifierDomain, from: 3, to: 8, params: ['∀', 'Logic'] }],
|
|
240
246
|
['∀a∈X1 F1[{a},X1]', { code: RSErrorCode.expectedLogic, from: 6, to: 16, params: ['ℬ(X1)'] }],
|
|
241
247
|
['(1=1)∪X1', { code: RSErrorCode.expectedSetexpr, from: 0, to: 5, params: ['Logic'] }],
|
|
242
248
|
['X1 & 1=1', { code: RSErrorCode.expectedLogic, from: 0, to: 2, params: ['ℬ(X1)'] }],
|
|
@@ -298,7 +298,12 @@ export class TypeAuditor {
|
|
|
298
298
|
return true;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
private childTypeDebool(
|
|
301
|
+
private childTypeDebool(
|
|
302
|
+
node: AstNode,
|
|
303
|
+
index: number,
|
|
304
|
+
errorCode: RSErrorCode,
|
|
305
|
+
operation?: string
|
|
306
|
+
): Typification | null {
|
|
302
307
|
const result = this.childTypification(node, index);
|
|
303
308
|
if (result === null) {
|
|
304
309
|
return null;
|
|
@@ -307,7 +312,30 @@ export class TypeAuditor {
|
|
|
307
312
|
return result;
|
|
308
313
|
}
|
|
309
314
|
if (result.typeID !== TypeID.collection) {
|
|
310
|
-
|
|
315
|
+
const params =
|
|
316
|
+
errorCode === RSErrorCode.invalidTypeOperation && operation !== undefined
|
|
317
|
+
? [operation, labelType(result)]
|
|
318
|
+
: [labelType(result)];
|
|
319
|
+
this.onError(errorCode, node.children[index], params);
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
return debool(result);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private childQuantifierDomain(node: AstNode, index: number, operator: string): Typification | null {
|
|
326
|
+
const result = this.visitChild(node, index);
|
|
327
|
+
if (result === null) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
if (!isTypification(result)) {
|
|
331
|
+
this.onError(RSErrorCode.invalidQuantifierDomain, node.children[index], [operator, labelType(result)]);
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
if (result.typeID === TypeID.anyTypification) {
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
if (result.typeID !== TypeID.collection) {
|
|
338
|
+
this.onError(RSErrorCode.invalidQuantifierDomain, node.children[index], [operator, labelType(result)]);
|
|
311
339
|
return null;
|
|
312
340
|
}
|
|
313
341
|
return debool(result);
|
|
@@ -415,7 +443,7 @@ export class TypeAuditor {
|
|
|
415
443
|
if (variable.typeID === TokenID.NT_TUPLE_DECL) {
|
|
416
444
|
return this.onError(RSErrorCode.invalidArgumentCortegeDeclare, variable);
|
|
417
445
|
}
|
|
418
|
-
const domain = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation);
|
|
446
|
+
const domain = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation, labelToken(TokenID.ITERATE));
|
|
419
447
|
if (domain === null) {
|
|
420
448
|
return null;
|
|
421
449
|
}
|
|
@@ -433,12 +461,13 @@ export class TypeAuditor {
|
|
|
433
461
|
}
|
|
434
462
|
|
|
435
463
|
private visitArithmetic(node: AstNode): ExpressionType | null {
|
|
464
|
+
const operator = labelRSLangNode(node);
|
|
436
465
|
const type1 = this.childTypification(node, 0);
|
|
437
466
|
if (type1 === null) {
|
|
438
467
|
return null;
|
|
439
468
|
}
|
|
440
469
|
if (!('isArithmetic' in type1 && type1.isArithmetic)) {
|
|
441
|
-
return this.onError(RSErrorCode.arithmeticNotSupported, node.children[0], [labelType(type1)]);
|
|
470
|
+
return this.onError(RSErrorCode.arithmeticNotSupported, node.children[0], [labelType(type1), operator]);
|
|
442
471
|
}
|
|
443
472
|
|
|
444
473
|
const type2 = this.childTypification(node, 1);
|
|
@@ -446,12 +475,12 @@ export class TypeAuditor {
|
|
|
446
475
|
return null;
|
|
447
476
|
}
|
|
448
477
|
if (!('isArithmetic' in type2 && type2.isArithmetic)) {
|
|
449
|
-
return this.onError(RSErrorCode.arithmeticNotSupported, node.children[1], [labelType(type2)]);
|
|
478
|
+
return this.onError(RSErrorCode.arithmeticNotSupported, node.children[1], [labelType(type2), operator]);
|
|
450
479
|
}
|
|
451
480
|
|
|
452
481
|
const result = mergeTypifications(type1, type2);
|
|
453
482
|
if (result === null) {
|
|
454
|
-
return this.onError(RSErrorCode.typesNotCompatible, node, [labelType(type1), labelType(type2)]);
|
|
483
|
+
return this.onError(RSErrorCode.typesNotCompatible, node, [labelType(type1), labelType(type2), operator]);
|
|
455
484
|
}
|
|
456
485
|
return result;
|
|
457
486
|
}
|
|
@@ -475,7 +504,7 @@ export class TypeAuditor {
|
|
|
475
504
|
}
|
|
476
505
|
|
|
477
506
|
if (!checkCompatibility(type1, type2)) {
|
|
478
|
-
return this.onError(RSErrorCode.typesNotCompatible, node, [labelType(type1), labelType(type2)]);
|
|
507
|
+
return this.onError(RSErrorCode.typesNotCompatible, node, [labelType(type1), labelType(type2), operator]);
|
|
479
508
|
}
|
|
480
509
|
return LogicT;
|
|
481
510
|
}
|
|
@@ -483,7 +512,8 @@ export class TypeAuditor {
|
|
|
483
512
|
private visitQuantifier(node: AstNode): ExpressionType | null {
|
|
484
513
|
this.locals.startScope();
|
|
485
514
|
|
|
486
|
-
const
|
|
515
|
+
const operator = labelRSLangNode(node);
|
|
516
|
+
const domain = this.childQuantifierDomain(node, 1, operator);
|
|
487
517
|
if (domain === null) {
|
|
488
518
|
return null;
|
|
489
519
|
} else if (!this.visitChildDeclaration(node, 0, domain)) {
|
|
@@ -511,6 +541,7 @@ export class TypeAuditor {
|
|
|
511
541
|
}
|
|
512
542
|
|
|
513
543
|
private visitEquals(node: AstNode): ExpressionType | null {
|
|
544
|
+
const operator = labelRSLangNode(node);
|
|
514
545
|
const type1 = this.childTypification(node, 0);
|
|
515
546
|
if (type1 === null) {
|
|
516
547
|
return null;
|
|
@@ -521,13 +552,14 @@ export class TypeAuditor {
|
|
|
521
552
|
return null;
|
|
522
553
|
}
|
|
523
554
|
if (!checkCompatibility(type1, type2)) {
|
|
524
|
-
return this.onError(RSErrorCode.typesNotCompatible, node, [labelType(type1), labelType(type2)]);
|
|
555
|
+
return this.onError(RSErrorCode.typesNotCompatible, node, [labelType(type1), labelType(type2), operator]);
|
|
525
556
|
}
|
|
526
557
|
return LogicT;
|
|
527
558
|
}
|
|
528
559
|
|
|
529
560
|
private visitSetexprPredicate(node: AstNode): ExpressionType | null {
|
|
530
|
-
|
|
561
|
+
const operator = labelRSLangNode(node);
|
|
562
|
+
let type2 = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation, operator);
|
|
531
563
|
if (type2 === null) {
|
|
532
564
|
return null;
|
|
533
565
|
}
|
|
@@ -542,11 +574,11 @@ export class TypeAuditor {
|
|
|
542
574
|
|
|
543
575
|
if (!checkCompatibility(type1, type2)) {
|
|
544
576
|
if (isSubset) {
|
|
545
|
-
return this.onError(RSErrorCode.typesNotEqual, node, [labelType(type1), labelType(type2)]);
|
|
577
|
+
return this.onError(RSErrorCode.typesNotEqual, node, [labelType(type1), labelType(type2), operator]);
|
|
546
578
|
} else {
|
|
547
579
|
return this.onError(RSErrorCode.invalidElementPredicate, node, [
|
|
548
580
|
labelType(type1),
|
|
549
|
-
|
|
581
|
+
operator,
|
|
550
582
|
labelType(bool(type2))
|
|
551
583
|
]);
|
|
552
584
|
}
|
|
@@ -619,19 +651,20 @@ export class TypeAuditor {
|
|
|
619
651
|
}
|
|
620
652
|
|
|
621
653
|
private visitSetexprBinary(node: AstNode): ExpressionType | null {
|
|
622
|
-
const
|
|
654
|
+
const operator = labelRSLangNode(node);
|
|
655
|
+
const type1 = this.childTypeDebool(node, 0, RSErrorCode.invalidTypeOperation, operator);
|
|
623
656
|
if (type1 === null) {
|
|
624
657
|
return null;
|
|
625
658
|
}
|
|
626
659
|
|
|
627
|
-
const type2 = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation);
|
|
660
|
+
const type2 = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation, operator);
|
|
628
661
|
if (type2 === null) {
|
|
629
662
|
return null;
|
|
630
663
|
}
|
|
631
664
|
|
|
632
665
|
const result = mergeTypifications(type1, type2);
|
|
633
666
|
if (result === null) {
|
|
634
|
-
return this.onError(RSErrorCode.typesNotEqual, node, [labelType(bool(type1)), labelType(bool(type2))]);
|
|
667
|
+
return this.onError(RSErrorCode.typesNotEqual, node, [labelType(bool(type1)), labelType(bool(type2)), operator]);
|
|
635
668
|
}
|
|
636
669
|
return bool(result);
|
|
637
670
|
}
|
|
@@ -707,6 +740,7 @@ export class TypeAuditor {
|
|
|
707
740
|
}
|
|
708
741
|
|
|
709
742
|
private visitFilter(node: AstNode): ExpressionType | null {
|
|
743
|
+
const operator = labelRSLangNode(node);
|
|
710
744
|
const indices = getNodeIndices(node);
|
|
711
745
|
const tupleParam = indices.length === node.children.length - 1;
|
|
712
746
|
if (!tupleParam && node.children.length > 2) {
|
|
@@ -750,9 +784,10 @@ export class TypeAuditor {
|
|
|
750
784
|
return null;
|
|
751
785
|
}
|
|
752
786
|
if (param.typeID !== TypeID.collection || !checkCompatibility(bases[child], debool(param))) {
|
|
753
|
-
return this.onError(RSErrorCode.
|
|
787
|
+
return this.onError(RSErrorCode.invalidFilterParameterType, node.children[child], [
|
|
754
788
|
labelType(param),
|
|
755
|
-
labelType(bool(bases[child]))
|
|
789
|
+
labelType(bool(bases[child])),
|
|
790
|
+
operator
|
|
756
791
|
]);
|
|
757
792
|
}
|
|
758
793
|
}
|
|
@@ -764,7 +799,11 @@ export class TypeAuditor {
|
|
|
764
799
|
const paramType = param;
|
|
765
800
|
const expected = bool(tuple(bases));
|
|
766
801
|
if (paramType.typeID !== TypeID.collection || !checkCompatibility(expected, paramType)) {
|
|
767
|
-
return this.onError(RSErrorCode.
|
|
802
|
+
return this.onError(RSErrorCode.invalidFilterParameterType, node.children[0], [
|
|
803
|
+
labelType(paramType),
|
|
804
|
+
labelType(expected),
|
|
805
|
+
operator
|
|
806
|
+
]);
|
|
768
807
|
}
|
|
769
808
|
}
|
|
770
809
|
return argument;
|
|
@@ -794,7 +833,12 @@ export class TypeAuditor {
|
|
|
794
833
|
private visitDeclarative(node: AstNode): ExpressionType | null {
|
|
795
834
|
this.locals.startScope();
|
|
796
835
|
|
|
797
|
-
const domain = this.childTypeDebool(
|
|
836
|
+
const domain = this.childTypeDebool(
|
|
837
|
+
node,
|
|
838
|
+
1,
|
|
839
|
+
RSErrorCode.invalidTypeOperation,
|
|
840
|
+
labelToken(TokenID.NT_DECLARATIVE_EXPR)
|
|
841
|
+
);
|
|
798
842
|
if (domain === null) {
|
|
799
843
|
return null;
|
|
800
844
|
} else if (!this.visitChildDeclaration(node, 0, domain)) {
|
|
@@ -826,7 +870,7 @@ export class TypeAuditor {
|
|
|
826
870
|
}
|
|
827
871
|
|
|
828
872
|
private visitIterate(node: AstNode): ExpressionType | null {
|
|
829
|
-
const domain = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation);
|
|
873
|
+
const domain = this.childTypeDebool(node, 1, RSErrorCode.invalidTypeOperation, labelToken(TokenID.ITERATE));
|
|
830
874
|
if (domain === null) {
|
|
831
875
|
return null;
|
|
832
876
|
}
|
|
@@ -868,7 +912,8 @@ export class TypeAuditor {
|
|
|
868
912
|
if (!checkCompatibility(iterationValue, initType)) {
|
|
869
913
|
return this.onError(RSErrorCode.typesNotEqual, node.children[iterationIndex], [
|
|
870
914
|
labelType(iterationValue),
|
|
871
|
-
labelType(initType)
|
|
915
|
+
labelType(initType),
|
|
916
|
+
labelToken(node.typeID as TokenID)
|
|
872
917
|
]);
|
|
873
918
|
}
|
|
874
919
|
|