@rsconcept/domain 1.7.7 → 1.8.1

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.
Files changed (60) hide show
  1. package/dist/{analyzer-DqjdciC5.d.ts → analyzer-iqAXyROE.d.ts} +2 -3
  2. package/dist/{arguments-extractor-Dd1lFom9.d.ts → arguments-extractor-ngatANBI.d.ts} +2 -2
  3. package/dist/{ast-annotations-CZCzs9Uk.d.ts → ast-annotations-D6KZDu12.d.ts} +2 -2
  4. package/dist/{calculator-Dt03dsnd.d.ts → calculator-k8BGIKmj.d.ts} +2 -2
  5. package/dist/index.d.ts +8 -8
  6. package/dist/library/index.d.ts +97 -1
  7. package/dist/library/index.js +283 -1
  8. package/dist/library/index.js.map +1 -0
  9. package/dist/library/oss-api.js +1 -1
  10. package/dist/library/rsengine.d.ts +1 -1
  11. package/dist/library/rsform-api.d.ts +13 -3
  12. package/dist/library/rsform-api.js +24 -2
  13. package/dist/library/rsform-api.js.map +1 -1
  14. package/dist/library/rsform.d.ts +2 -2
  15. package/dist/library/rsmodel-api.d.ts +1 -1
  16. package/dist/library/structure-planner.d.ts +1 -1
  17. package/dist/library/structure-planner.js +1 -1
  18. package/dist/rslang/api.d.ts +13 -2
  19. package/dist/rslang/api.js +31 -2
  20. package/dist/rslang/api.js.map +1 -1
  21. package/dist/rslang/ast-annotations.d.ts +1 -1
  22. package/dist/rslang/eval/calculator.d.ts +1 -1
  23. package/dist/rslang/eval/value-api.d.ts +1 -1
  24. package/dist/rslang/index.d.ts +8 -8
  25. package/dist/rslang/labels.d.ts +4 -2
  26. package/dist/rslang/labels.js +8 -2
  27. package/dist/rslang/labels.js.map +1 -1
  28. package/dist/rslang/parser/syntax-errors/index.d.ts +1 -1
  29. package/dist/rslang/semantic/analyzer.d.ts +1 -1
  30. package/dist/rslang/semantic/analyzer.js +5 -13
  31. package/dist/rslang/semantic/analyzer.js.map +1 -1
  32. package/dist/rslang/semantic/arguments-extractor.d.ts +1 -1
  33. package/dist/rslang/semantic/type-auditor.d.ts +1 -1
  34. package/dist/rslang/semantic/type-auditor.js +2 -2
  35. package/dist/rslang/semantic/type-auditor.js.map +1 -1
  36. package/dist/rslang/semantic/typification-api.d.ts +1 -1
  37. package/dist/rslang/semantic/typification-parser.d.ts +1 -1
  38. package/dist/rslang/semantic/typification.d.ts +2 -2
  39. package/dist/rslang/semantic/typification.js +14 -6
  40. package/dist/rslang/semantic/typification.js.map +1 -1
  41. package/dist/rslang/typification-graph.d.ts +1 -1
  42. package/dist/{typification-DDuv88ir.d.ts → typification-9lNu9R4k.d.ts} +8 -4
  43. package/dist/{typification-graph-8VdK6_Fh.d.ts → typification-graph-BY_oGT82.d.ts} +2 -2
  44. package/dist/{typification-parser-DHO42ZRc.d.ts → typification-parser-Dytsv9CI.d.ts} +2 -2
  45. package/dist/{value-api-C2X4Pom5.d.ts → value-api-CXLl_zg0.d.ts} +2 -2
  46. package/package.json +1 -1
  47. package/src/library/index.ts +8 -0
  48. package/src/library/rsform-api.test.ts +11 -1
  49. package/src/library/rsform-api.ts +40 -1
  50. package/src/library/template-instantiation.test.ts +427 -0
  51. package/src/library/template-instantiation.ts +456 -0
  52. package/src/rslang/api.test.ts +28 -0
  53. package/src/rslang/api.ts +32 -2
  54. package/src/rslang/labels.ts +10 -1
  55. package/src/rslang/semantic/analyzer.ts +6 -14
  56. package/src/rslang/semantic/type-auditor.test.ts +25 -6
  57. package/src/rslang/semantic/type-auditor.ts +2 -1
  58. package/src/rslang/semantic/typification-api.test.ts +21 -5
  59. package/src/rslang/semantic/typification-parser.test.ts +6 -1
  60. package/src/rslang/semantic/typification.ts +16 -6
@@ -20,6 +20,7 @@ import {
20
20
  isTemplateRadical,
21
21
  isTypification,
22
22
  LogicT,
23
+ mangleParamAlias,
23
24
  mangleRadicalId,
24
25
  type Parametrized,
25
26
  tuple,
@@ -1025,7 +1026,7 @@ export class TypeAuditor {
1025
1026
  substituteBase(expectedType, substitutes);
1026
1027
  }
1027
1028
  this.onError(RSErrorCode.invalidArgumentType, node.children[child], [
1028
- `${type.args[child - 1].alias}∈${labelType(expectedType)}`,
1029
+ `${mangleParamAlias(type.args[child - 1].alias, alias)}∈${labelType(expectedType)}`,
1029
1030
  labelType(childType)
1030
1031
  ]);
1031
1032
  return null;
@@ -1,7 +1,16 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import type { TypePath } from './typification';
4
- import { AnyTypificationT, basic, bool, IntegerT, mangleRadicalId, tuple, type Typification } from './typification';
4
+ import {
5
+ AnyTypificationT,
6
+ basic,
7
+ bool,
8
+ IntegerT,
9
+ mangleParamAlias,
10
+ mangleRadicalId,
11
+ tuple,
12
+ type Typification
13
+ } from './typification';
5
14
  import { applyPath, cloneTypification, compareTemplated, substituteBase } from './typification-api';
6
15
 
7
16
  describe('applyPath', () => {
@@ -56,15 +65,22 @@ describe('compareTemplated', () => {
56
65
 
57
66
  describe('mangleRadicalId', () => {
58
67
  it('qualifies template radical with function name', () => {
59
- expect(mangleRadicalId('R1', 'P2')).toBe('R1<P2>');
60
- expect(mangleRadicalId('R2', 'F10')).toBe('R2<F10>');
68
+ expect(mangleRadicalId('R1', 'P2')).toBe('P2<R1>');
69
+ expect(mangleRadicalId('R2', 'F10')).toBe('F10<R2>');
70
+ });
71
+ });
72
+
73
+ describe('mangleParamAlias', () => {
74
+ it('qualifies formal parameter alias with calling function name', () => {
75
+ expect(mangleParamAlias('β', 'P44')).toBe('P44<β>');
76
+ expect(mangleParamAlias('a', 'F1')).toBe('F1<a>');
61
77
  });
62
78
  });
63
79
 
64
80
  describe('cloneTypification + substituteBase', () => {
65
81
  it('resolves mangled radicals for error messages', () => {
66
- const argType = bool(basic('R1<F2>'));
67
- const substitutes = new Map<string, Typification>([['R1<F2>', basic('X1')]]);
82
+ const argType = bool(basic('F2<R1>'));
83
+ const substitutes = new Map<string, Typification>([['F2<R1>', basic('X1')]]);
68
84
  const expectedType = cloneTypification(argType);
69
85
  substituteBase(expectedType, substitutes);
70
86
  expect(expectedType).toEqual(bool(basic('X1')));
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { labelType } from '../labels';
3
+ import { labelBaseId, labelType } from '../labels';
4
4
 
5
5
  import { TypeID } from './typification';
6
6
  import { applyAsciiTypeSubstitutions, parseTypeText } from './typification-parser';
@@ -47,4 +47,9 @@ describe('parseTypeText', () => {
47
47
  expect(applyAsciiTypeSubstitutions('X1*X2 -> X3')).toBe('X1×X2 → X3');
48
48
  expect(applyAsciiTypeSubstitutions('B(X1)')).toBe('ℬ(X1)');
49
49
  });
50
+
51
+ it('displays mangled radicals with function qualifier before radical', () => {
52
+ expect(labelBaseId('P44<R3>')).toBe('<P44>R3');
53
+ expect(labelType({ typeID: TypeID.basic, baseID: 'P2<R1>' })).toBe('<P2>R1');
54
+ });
50
55
  });
@@ -174,17 +174,27 @@ export function isTypification(type: ExpressionType | null): boolean {
174
174
  );
175
175
  }
176
176
 
177
- /** Checks if given alias is a template or mangled radical. */
178
- export function isRadical(alias: string): boolean {
179
- return /^R[1-9]\d*(?:<[^>]+>)?$/.test(alias);
180
- }
181
-
182
177
  /** Checks if given alias is an unmangled template radical. */
183
178
  export function isTemplateRadical(alias: string): boolean {
184
179
  return /^R[1-9]\d*$/.test(alias);
185
180
  }
186
181
 
182
+ /** Checks if given alias is a mangled template radical (`funcName<R#>`). */
183
+ export function isMangledRadical(alias: string): boolean {
184
+ return /^[^<]+<R[1-9]\d*>$/.test(alias);
185
+ }
186
+
187
+ /** Checks if given alias is a template or mangled radical. */
188
+ export function isRadical(alias: string): boolean {
189
+ return isTemplateRadical(alias) || isMangledRadical(alias);
190
+ }
191
+
187
192
  /** Mangle template radical with calling function name. */
188
193
  export function mangleRadicalId(radical: string, funcName: string): string {
189
- return `${radical}<${funcName}>`;
194
+ return `${funcName}<${radical}>`;
195
+ }
196
+
197
+ /** Mangle formal parameter alias with calling function name (for diagnostics). */
198
+ export function mangleParamAlias(alias: string, funcName: string): string {
199
+ return `${funcName}<${alias}>`;
190
200
  }