yukigo 0.2.2 → 0.2.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.2.3 (2026-05-02)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **yukigo:** fix bugs on MulangAdapter ([7fc193d](https://github.com/miyukiproject/yukigo/commit/7fc193d))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - noiseArch
10
+
1
11
  ## 0.2.2 (2026-05-01)
2
12
 
3
13
  ### 🩹 Fixes
@@ -24,7 +24,6 @@ export declare class Declares extends ScopedVisitor {
24
24
  visitVariable(node: Variable): void;
25
25
  visitAttribute(node: Attribute): void;
26
26
  visitTypeAlias(node: TypeAlias): void;
27
- visitTypeSignature(node: TypeSignature): void;
28
27
  }
29
28
  export declare class DeclaresComputation extends ScopedVisitor {
30
29
  private readonly callName;
@@ -62,7 +61,7 @@ export declare class DeclaresRecursively extends ScopedVisitor {
62
61
  visitRule(node: Rule): void;
63
62
  visitNested(node: ASTNode): void;
64
63
  }
65
- export declare class HasDirectRecursion extends TraverseVisitor {
64
+ export declare class UsesDirectRecursion extends TraverseVisitor {
66
65
  private readonly binding;
67
66
  private isInsideBody;
68
67
  constructor(binding: string);
@@ -88,9 +88,6 @@ let Declares = class Declares extends ScopedVisitor {
88
88
  visitTypeAlias(node) {
89
89
  this.check(node);
90
90
  }
91
- visitTypeSignature(node) {
92
- this.check(node);
93
- }
94
91
  };
95
92
  Declares = __decorate([
96
93
  AutoScoped
@@ -215,7 +212,7 @@ DeclaresRecursively = __decorate([
215
212
  AutoScoped
216
213
  ], DeclaresRecursively);
217
214
  export { DeclaresRecursively };
218
- export class HasDirectRecursion extends TraverseVisitor {
215
+ export class UsesDirectRecursion extends TraverseVisitor {
219
216
  binding;
220
217
  isInsideBody = false;
221
218
  constructor(binding) {
@@ -576,7 +573,7 @@ export const genericInspections = {
576
573
  DeclaresEntryPoint: DeclaresEntryPoint,
577
574
  DeclaresFunction: DeclaresFunction,
578
575
  DeclaresRecursively: DeclaresRecursively,
579
- HasDirectRecursion: HasDirectRecursion,
576
+ UsesDirectRecursion: UsesDirectRecursion,
580
577
  DeclaresTypeAlias: DeclaresTypeAlias,
581
578
  DeclaresTypeSignature: DeclaresTypeSignature,
582
579
  HasTypeSignature: DeclaresTypeSignature,
@@ -4,8 +4,14 @@ const declareMap = {
4
4
  HasTypeDeclaration: "DeclaresTypeAlias",
5
5
  HasTypeSignature: "DeclaresTypeSignature",
6
6
  HasVariable: "DeclaresVariable",
7
- HasDirectRecursion: "DeclaresRecursively",
8
7
  };
8
+ const V0_HAS_INSPECTIONS = new Set([
9
+ "HasBinding", "HasTypeDeclaration", "HasTypeSignature", "HasVariable",
10
+ "HasArity", "HasDirectRecursion", "HasComposition", "HasComprehension",
11
+ "HasForeach", "HasIf", "HasGuards", "HasConditional", "HasLambda",
12
+ "HasRepeat", "HasWhile", "HasUsage", "HasAnonymousVariable",
13
+ "HasNot", "HasForall", "HasFindall",
14
+ ]);
9
15
  const NEGATION_PREFIXES = new Set(["Not", "Except"]);
10
16
  const SUFFIX_ARGS = new Set(["like", "except"]);
11
17
  const isValidFormat = (inspection) => typeof inspection === "object" &&
@@ -79,15 +85,12 @@ export class MulangAdapter {
79
85
  };
80
86
  if (inspection === "HasArity")
81
87
  return {
82
- inspection: `DeclaresComputationWithArity${args[0]}`,
83
- ...promoteBindingToTarget([], binding),
84
- };
85
- if (inspection.startsWith("Has"))
86
- return {
87
- inspection: inspection.replace(/^Has(Usage)?/, (_, usage) => usage ? "Uses" : "Uses"),
88
- args,
89
- binding,
88
+ inspection: "DeclaresComputationWithArity",
89
+ args: [args[0], ...(binding && binding !== "*" ? [binding] : [])],
90
+ binding: "*",
90
91
  };
92
+ if (V0_HAS_INSPECTIONS.has(inspection))
93
+ return { inspection: inspection === "HasUsage" ? "Uses" : inspection.replace(/^Has/, "Uses"), args, binding };
91
94
  return { inspection, args, binding };
92
95
  }
93
96
  retrieveArguments(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yukigo",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -119,10 +119,6 @@ export class Declares extends ScopedVisitor {
119
119
  visitTypeAlias(node: TypeAlias): void {
120
120
  this.check(node);
121
121
  }
122
-
123
- visitTypeSignature(node: TypeSignature): void {
124
- this.check(node);
125
- }
126
122
  }
127
123
  @AutoScoped
128
124
  export class DeclaresComputation extends ScopedVisitor {
@@ -234,7 +230,7 @@ export class DeclaresRecursively extends ScopedVisitor {
234
230
  throw new StopTraversalException();
235
231
  }
236
232
  }
237
- export class HasDirectRecursion extends TraverseVisitor {
233
+ export class UsesDirectRecursion extends TraverseVisitor {
238
234
  private isInsideBody: boolean = false;
239
235
  constructor(private readonly binding: string) {
240
236
  super();
@@ -553,7 +549,7 @@ export const genericInspections: Record<string, VisitorConstructor> = {
553
549
  DeclaresEntryPoint: DeclaresEntryPoint,
554
550
  DeclaresFunction: DeclaresFunction,
555
551
  DeclaresRecursively: DeclaresRecursively,
556
- HasDirectRecursion: HasDirectRecursion,
552
+ UsesDirectRecursion: UsesDirectRecursion,
557
553
  DeclaresTypeAlias: DeclaresTypeAlias,
558
554
  DeclaresTypeSignature: DeclaresTypeSignature,
559
555
  HasTypeSignature: DeclaresTypeSignature,
@@ -9,8 +9,14 @@ const declareMap: Record<string, string> = {
9
9
  HasTypeDeclaration: "DeclaresTypeAlias",
10
10
  HasTypeSignature: "DeclaresTypeSignature",
11
11
  HasVariable: "DeclaresVariable",
12
- HasDirectRecursion: "DeclaresRecursively",
13
12
  };
13
+ const V0_HAS_INSPECTIONS = new Set([
14
+ "HasBinding", "HasTypeDeclaration", "HasTypeSignature", "HasVariable",
15
+ "HasArity", "HasDirectRecursion", "HasComposition", "HasComprehension",
16
+ "HasForeach", "HasIf", "HasGuards", "HasConditional", "HasLambda",
17
+ "HasRepeat", "HasWhile", "HasUsage", "HasAnonymousVariable",
18
+ "HasNot", "HasForall", "HasFindall",
19
+ ]);
14
20
 
15
21
  type MulangInspection = {
16
22
  inspection: string;
@@ -113,18 +119,13 @@ export class MulangAdapter {
113
119
 
114
120
  if (inspection === "HasArity")
115
121
  return {
116
- inspection: `DeclaresComputationWithArity${args[0]}`,
117
- ...promoteBindingToTarget([], binding),
122
+ inspection: "DeclaresComputationWithArity",
123
+ args: [args[0], ...(binding && binding !== "*" ? [binding] : [])],
124
+ binding: "*",
118
125
  };
119
126
 
120
- if (inspection.startsWith("Has"))
121
- return {
122
- inspection: inspection.replace(/^Has(Usage)?/, (_, usage) =>
123
- usage ? "Uses" : "Uses",
124
- ),
125
- args,
126
- binding,
127
- };
127
+ if (V0_HAS_INSPECTIONS.has(inspection))
128
+ return { inspection: inspection === "HasUsage" ? "Uses" : inspection.replace(/^Has/, "Uses"), args, binding };
128
129
 
129
130
  return { inspection, args, binding };
130
131
  }
@@ -12,10 +12,10 @@ expectations:
12
12
  inspection: HasBinding
13
13
  - !ruby/hash:ActiveSupport::HashWithIndifferentAccess
14
14
  binding: squareList
15
- inspection: HasLambdaExpression
15
+ inspection: HasLambda
16
16
  - !ruby/hash:ActiveSupport::HashWithIndifferentAccess
17
17
  binding: square
18
- inspection: HasArithmetic
18
+ inspection: UsesArithmetic
19
19
  - !ruby/hash:ActiveSupport::HashWithIndifferentAccess
20
20
  binding: doble
21
21
  inspection: Not:HasBinding
@@ -41,7 +41,7 @@ expectations:
41
41
  targetSuffix: "named",
42
42
  },
43
43
  {
44
- inspection: "UsesLambdaExpression",
44
+ inspection: "UsesLambda",
45
45
  binding: "squareList",
46
46
  args: [],
47
47
  expected: true,