@shd101wyy/yo 0.1.27 → 0.1.29

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 (63) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +15 -15
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +110 -121
  3. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +3 -0
  4. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +2 -0
  5. package/.github/skills/yo-syntax/SKILL.md +2 -2
  6. package/.github/skills/yo-syntax/syntax-cheatsheet.md +195 -73
  7. package/README.md +2 -0
  8. package/out/cjs/index.cjs +624 -613
  9. package/out/cjs/yo-cli.cjs +739 -727
  10. package/out/cjs/yo-lsp.cjs +636 -625
  11. package/out/esm/index.mjs +526 -515
  12. package/out/types/src/codegen/functions/declarations.d.ts +1 -1
  13. package/out/types/src/doc/model.d.ts +0 -1
  14. package/out/types/src/env.d.ts +1 -2
  15. package/out/types/src/evaluator/calls/helper.d.ts +4 -2
  16. package/out/types/src/evaluator/context.d.ts +1 -1
  17. package/out/types/src/evaluator/exprs/{escape.d.ts → unwind.d.ts} +1 -1
  18. package/out/types/src/evaluator/types/function.d.ts +1 -2
  19. package/out/types/src/evaluator/types/synthesizer.d.ts +1 -0
  20. package/out/types/src/evaluator/utils.d.ts +0 -1
  21. package/out/types/src/expr.d.ts +5 -6
  22. package/out/types/src/test-runner.d.ts +2 -0
  23. package/out/types/src/types/creators.d.ts +4 -6
  24. package/out/types/src/types/definitions.d.ts +7 -16
  25. package/out/types/src/types/guards.d.ts +1 -2
  26. package/out/types/src/types/tags.d.ts +0 -1
  27. package/out/types/src/types/utils.d.ts +1 -0
  28. package/out/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
  30. package/scripts/probe-parser-parity.ts +61 -0
  31. package/scripts/probe-yo-self-parser.sh +33 -0
  32. package/scripts/validate-yo-self-fmt.ts +184 -0
  33. package/std/async.yo +1 -1
  34. package/std/crypto/random.yo +6 -6
  35. package/std/encoding/base64.yo +4 -4
  36. package/std/encoding/hex.yo +2 -2
  37. package/std/encoding/json.yo +3 -3
  38. package/std/encoding/utf16.yo +1 -1
  39. package/std/error.yo +14 -2
  40. package/std/fs/dir.yo +56 -62
  41. package/std/fs/file.yo +118 -124
  42. package/std/fs/metadata.yo +11 -17
  43. package/std/fs/temp.yo +21 -27
  44. package/std/fs/walker.yo +10 -16
  45. package/std/http/client.yo +25 -29
  46. package/std/http/index.yo +4 -4
  47. package/std/io/reader.yo +1 -1
  48. package/std/io/writer.yo +2 -2
  49. package/std/net/addr.yo +1 -1
  50. package/std/net/dns.yo +10 -14
  51. package/std/net/errors.yo +1 -1
  52. package/std/net/tcp.yo +67 -71
  53. package/std/net/udp.yo +36 -40
  54. package/std/os/signal.yo +2 -2
  55. package/std/prelude.yo +27 -21
  56. package/std/process/command.yo +32 -38
  57. package/std/regex/parser.yo +10 -10
  58. package/std/sys/bufio/buf_reader.yo +14 -14
  59. package/std/sys/bufio/buf_writer.yo +17 -17
  60. package/std/sys/errors.yo +1 -1
  61. package/std/thread.yo +2 -2
  62. package/std/url/index.yo +2 -2
  63. package/std/worker.yo +2 -2
@@ -10,7 +10,7 @@ export interface EvidenceParameter {
10
10
  fieldFunctionType: FunctionType;
11
11
  cParamName: string;
12
12
  }
13
- export declare function getEvidenceParameters(functionType: FunctionType): EvidenceParameter[];
13
+ export declare function getEvidenceParameters(_functionType: FunctionType): EvidenceParameter[];
14
14
  export declare function generateFunctionPrototype(functionType: FunctionType, cFunctionName: string, context: CodeGenContext, overrideReturnType?: string, originalFunctionType?: FunctionType): string;
15
15
  export declare function generateFunctionDeclaration(functionType: FunctionType, cFunctionName: string, isExtern: boolean, context: CodeGenContext, functionBody?: Expr, originalFunctionType?: FunctionType): void;
16
16
  export declare function generateObjectConstructorDeclarations(context: FunctionGenerationContext): void;
@@ -3,7 +3,6 @@ export interface DocParam {
3
3
  name: string;
4
4
  type: string;
5
5
  isComptime: boolean;
6
- isImplicit: boolean;
7
6
  defaultValue?: string;
8
7
  doc?: string;
9
8
  }
@@ -17,7 +17,6 @@ export interface Variable {
17
17
  token: Token;
18
18
  isCreatedFromDestructuringAtomVariable?: boolean;
19
19
  parameterAlias?: string;
20
- isImplicit?: boolean;
21
20
  isFromEffectSpread?: boolean;
22
21
  isEffectParam?: boolean;
23
22
  isModuleLevel?: boolean;
@@ -85,6 +84,7 @@ export declare function addVariableToFrame({ frame, variable, }: {
85
84
  frame: Frame;
86
85
  variable: Variable;
87
86
  }): Frame;
87
+ export declare function _printFrameIndexStats(): void;
88
88
  export declare function getVariablesFromFrame(frame: Frame, variableName: string, variableFilter?: (variable: Variable) => boolean): Variable[];
89
89
  export declare function getVariablesFromEnv(env: Environment, variableName: string, variableFilter?: (variable: Variable) => boolean): Variable[];
90
90
  export declare function findVariableFrameLevel(env: Environment, variableName: string): number | undefined;
@@ -128,7 +128,6 @@ export declare function getReceiverMethodsByNameFromEnv({ env, context, methodNa
128
128
  value: Value | undefined;
129
129
  needsPointerConversion?: boolean;
130
130
  }[];
131
- export declare function stripImplicitVariablesFromEnv(env: Environment): Environment;
132
131
  export declare function keepTopLevelFrameAndComptimeVariablesFromEnv(env: Environment): Environment;
133
132
  export declare function getVariablesNeedingDrop(env: Environment): Variable[];
134
133
  export declare function findNearestBeginBlockFrameLevel(env: Environment): number;
@@ -25,7 +25,7 @@ export declare function checkIfFunctionParameterMatchesArgument({ functionType,
25
25
  };
26
26
  export declare function extractFunctionValue(value: Value | undefined): FunctionValue | undefined;
27
27
  export declare function _printCallProfile(): void;
28
- export declare function tryToCallFunctionWithArguments({ expr, functionValue, functionType, functionCalleeExpr, argExprs, callerEnv, context, isMethodCall, skipSpecialization, skipCtfeExecution, }: {
28
+ type TryToCallArgs = {
29
29
  functionValue?: FunctionValue;
30
30
  functionType: FunctionType;
31
31
  expr?: Expr;
@@ -36,10 +36,12 @@ export declare function tryToCallFunctionWithArguments({ expr, functionValue, fu
36
36
  isMethodCall: boolean;
37
37
  skipSpecialization?: boolean;
38
38
  skipCtfeExecution?: boolean;
39
- }): FunctionCallResult;
39
+ };
40
+ export declare function tryToCallFunctionWithArguments(args: TryToCallArgs): FunctionCallResult;
40
41
  export declare function validateFunctionReturnType({ returnType, expr, env, context, }: {
41
42
  returnType: Type;
42
43
  expr: Expr | undefined;
43
44
  env: Environment;
44
45
  context: EvaluatorContext;
45
46
  }): void;
47
+ export {};
@@ -54,6 +54,7 @@ export interface EvaluatorContext {
54
54
  stdPath: string;
55
55
  currentModulePath?: string;
56
56
  isUnsafeFunctionType?: boolean;
57
+ isControlFunctionType?: boolean;
57
58
  enclosingFunctionReturnType?: Type;
58
59
  hasControlFunctionImplicitParams?: boolean;
59
60
  isInsideWhereClause?: boolean;
@@ -67,7 +68,6 @@ export interface EvaluatorContext {
67
68
  isAnalyzingCtfeCapability?: boolean;
68
69
  isInFunctionCallCheckingPhase?: boolean;
69
70
  isInsideIoAsyncCall?: boolean;
70
- isInsideGivenHandler?: boolean;
71
71
  isEvaluatingGenericImplSpecialization?: boolean;
72
72
  currentlySpecializingFunction?: {
73
73
  originalFuncId: string;
@@ -1,7 +1,7 @@
1
1
  import { type Environment } from "../../env";
2
2
  import { type Expr, type FnCallExpr } from "../../expr";
3
3
  import type { EvaluatorContext } from "../context";
4
- export declare function evaluateEscape({ expr, env, context, }: {
4
+ export declare function evaluateUnwind({ expr, env, context, }: {
5
5
  expr: FnCallExpr;
6
6
  env: Environment;
7
7
  context: EvaluatorContext;
@@ -1,6 +1,6 @@
1
1
  import { type Environment } from "../../env";
2
2
  import { type Expr, type FnCallExpr } from "../../expr";
3
- import type { FunctionImplicitParameter, FunctionParameter, FunctionType, Type } from "../../types/definitions";
3
+ import type { FunctionParameter, FunctionType, Type } from "../../types/definitions";
4
4
  import type { EvaluatorContext } from "../context";
5
5
  export declare function evaluateFunctionParameter({ expr, env, context, isParameterComptimeByDefault, allowVariableShadowing, }: {
6
6
  expr: Expr;
@@ -32,7 +32,6 @@ export declare function evaluateFunctionParameters({ parameterExprs, env, contex
32
32
  }): {
33
33
  parameters: FunctionParameter[];
34
34
  forallParameters: FunctionParameter[];
35
- implicitParameters: FunctionImplicitParameter[];
36
35
  variadicParameter?: FunctionParameter;
37
36
  whereClauseExprs?: Expr[];
38
37
  env: Environment;
@@ -6,6 +6,7 @@ export interface SynthesizeTypesOptions {
6
6
  setResolvedConcreteType?: boolean;
7
7
  token?: Token;
8
8
  }
9
+ export declare function _printSynthStats(): void;
9
10
  export declare function synthesizeTypes(expected: {
10
11
  type: Type;
11
12
  env: Environment;
@@ -2,4 +2,3 @@ import { type Environment, type Variable } from "../env";
2
2
  import { type Expr } from "../expr";
3
3
  export declare function isValidVariableName(expr: Expr): boolean;
4
4
  export declare function findRcValueOwnerRelationship(rhs: Expr, env: Environment, _modulePath: string): Variable | undefined;
5
- export declare function throwExprIsImplicitVariableError(rhs: Expr): void;
@@ -39,12 +39,12 @@ export interface RuntimeDestructuring {
39
39
  }
40
40
  export type ControlFlowFlags = {
41
41
  return?: boolean;
42
- escape?: boolean;
42
+ unwind?: boolean;
43
43
  break?: boolean;
44
44
  continue?: boolean;
45
45
  };
46
- export declare function controlFlowOf(kind: "return" | "escape" | "break" | "continue"): ControlFlowFlags;
47
- export declare function hasControlFlow(cf: ControlFlowFlags | undefined, kind: "return" | "escape" | "break" | "continue"): boolean;
46
+ export declare function controlFlowOf(kind: "return" | "unwind" | "break" | "continue"): ControlFlowFlags;
47
+ export declare function hasControlFlow(cf: ControlFlowFlags | undefined, kind: "return" | "unwind" | "break" | "continue"): boolean;
48
48
  export declare function hasAnyControlFlow(cf: ControlFlowFlags | undefined): boolean;
49
49
  export declare function mergeControlFlows(flows: ControlFlowFlags[]): ControlFlowFlags;
50
50
  export declare function controlFlowToString(cf: ControlFlowFlags): string;
@@ -118,8 +118,6 @@ export declare const BuiltinKeywords: {
118
118
  runtime: string[];
119
119
  ref: string[];
120
120
  forall: string[];
121
- using: string[];
122
- given: string[];
123
121
  where: string[];
124
122
  quote: string[];
125
123
  unquote: string[];
@@ -128,7 +126,8 @@ export declare const BuiltinKeywords: {
128
126
  recur: string[];
129
127
  fn: string[];
130
128
  unsafe_fn: string[];
131
- escape: string[];
129
+ ctl: string[];
130
+ unwind: string[];
132
131
  extern: string[];
133
132
  cond: string[];
134
133
  type: string[];
@@ -1,4 +1,5 @@
1
1
  import { type Expr } from "./expr";
2
+ export declare const DEFAULT_TEST_BATCH_SIZE = 100;
2
3
  export interface TestDeclaration {
3
4
  name: string;
4
5
  bodyExpr: Expr;
@@ -37,4 +38,5 @@ export declare function runTests(testFiles: string[], options?: {
37
38
  keepGeneratedFiles?: boolean;
38
39
  profile?: boolean;
39
40
  noSanitize?: boolean;
41
+ testBatchSize?: number;
40
42
  }): Promise<TestRunSummary>;
@@ -3,7 +3,7 @@ import type { EvaluatorContext } from "../evaluator/context";
3
3
  import type { Expr } from "../expr";
4
4
  import type { FunctionValue } from "../function-value";
5
5
  import { type Value } from "../value";
6
- import type { ArrayType, ComptimeListType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionForallParameter, FunctionImplicitParameter, FunctionParameter, FunctionParameterExprs, FunctionReturn, FunctionType, FutureTraitType, IsoType, SourceNamespaceType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, TypeField, TypeHierarchyType, UnionType, VoidType } from "./definitions";
6
+ import type { ArrayType, ComptimeListType, DynType, EnumType, FnTraitType, FunctionForallParameter, FunctionParameter, FunctionParameterExprs, FutureEffect, FunctionReturn, FunctionType, FutureTraitType, IsoType, SourceNamespaceType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, TypeField, TypeHierarchyType, UnionType, VoidType } from "./definitions";
7
7
  export declare function createComptimeIntType(): Type;
8
8
  export declare function createComptimeFloatType(): Type;
9
9
  export declare function createComptimeStringType(): Type;
@@ -45,10 +45,9 @@ export declare function createSourceNamespaceType(env: Environment): SourceNames
45
45
  export declare function createTraitType(env: Environment): TraitType;
46
46
  export declare function createEnumType(env: Environment): EnumType;
47
47
  export declare function createUnionType(env: Environment): UnionType;
48
- export declare function createFunctionType({ parameters, forallParameters, implicitParameters, variadicParameter, whereClauseExprs, return_, env, parametersFrame, SelfType, SelfTraitType, isClosure, }: {
48
+ export declare function createFunctionType({ parameters, forallParameters, variadicParameter, whereClauseExprs, return_, env, parametersFrame, SelfType, SelfTraitType, isClosure, isControl, }: {
49
49
  parameters: FunctionParameter[];
50
50
  forallParameters: FunctionForallParameter[];
51
- implicitParameters?: FunctionImplicitParameter[];
52
51
  variadicParameter: FunctionParameter | undefined;
53
52
  whereClauseExprs?: Expr[];
54
53
  return_: FunctionReturn;
@@ -57,6 +56,7 @@ export declare function createFunctionType({ parameters, forallParameters, impli
57
56
  SelfType?: Type;
58
57
  SelfTraitType?: Type;
59
58
  isClosure?: boolean;
59
+ isControl?: boolean;
60
60
  }): FunctionType;
61
61
  export declare function createPtrType(childType: Type): PtrType;
62
62
  export declare function createIsoType(childType: Type, env: Environment): IsoType;
@@ -71,8 +71,6 @@ export declare function createSomeType(type: TypeHierarchyType, variableName: st
71
71
  env: Environment;
72
72
  context: EvaluatorContext;
73
73
  }): SomeType;
74
- export declare function createEffectsRowSomeType(variableName: string, env: Environment): SomeType;
75
- export declare function createEffectsRowType(implicitParameters: FunctionImplicitParameter[]): EffectsRowType;
76
74
  export declare function createTypeHierarchy(level: number, baseType?: Type): TypeHierarchyType;
77
75
  export declare function getFunctionParameterExprs({ expr, labelExpr, typeExpr, defaultValueExpr, assignedValueExpr, }: {
78
76
  expr: Expr;
@@ -82,7 +80,7 @@ export declare function getFunctionParameterExprs({ expr, labelExpr, typeExpr, d
82
80
  assignedValueExpr: Expr | undefined;
83
81
  }): FunctionParameterExprs;
84
82
  export declare function createFnTraitType(fnType: FunctionType, env: Environment): FnTraitType;
85
- export declare function createFutureTraitType(outputType: Type, env: Environment, effects?: FunctionImplicitParameter[]): FutureTraitType;
83
+ export declare function createFutureTraitType(outputType: Type, env: Environment, effect?: FutureEffect): FutureTraitType;
86
84
  export declare function createDynType({ requiredTraits, env, negativeTraits, }: {
87
85
  requiredTraits: TraitType[];
88
86
  env: Environment;
@@ -53,14 +53,8 @@ export interface SomeType extends Type {
53
53
  functionValue: FunctionValue;
54
54
  argValues: Value[];
55
55
  };
56
- isEffectsRow?: boolean;
57
56
  kindFunctionType?: FunctionType;
58
57
  }
59
- export interface EffectsRowType extends Type {
60
- tag: TypeTag.EffectsRow;
61
- implicitParameters: FunctionImplicitParameter[];
62
- trait: TraitType;
63
- }
64
58
  export interface TypeApplicationType extends Type {
65
59
  tag: TypeTag.TypeApplication;
66
60
  constructor: SomeType;
@@ -119,18 +113,11 @@ export interface FunctionParameter {
119
113
  isCompileTimeOnly: boolean;
120
114
  isQuote: boolean;
121
115
  isOwningTheRcValue: boolean;
122
- isImplicit: boolean;
123
- isEffectRowSpread?: boolean;
124
116
  exprs: FunctionParameterExprs;
125
117
  assignedValue?: Value;
126
118
  }
127
119
  export type FunctionForallParameter = FunctionParameter & {
128
120
  isCompileTimeOnly: true;
129
- isImplicit: false;
130
- };
131
- export type FunctionImplicitParameter = FunctionParameter & {
132
- isCompileTimeOnly: true;
133
- isImplicit: true;
134
121
  };
135
122
  export interface StructType extends Type {
136
123
  tag: TypeTag.Struct;
@@ -164,7 +151,7 @@ export interface TraitType extends Type {
164
151
  };
165
152
  isFuture?: {
166
153
  outputType: Type;
167
- effects: FunctionImplicitParameter[];
154
+ effect?: FutureEffect;
168
155
  };
169
156
  isConcrete?: {
170
157
  concreteType: Type;
@@ -181,10 +168,14 @@ export type FnTraitType = TraitType & {
181
168
  callType: FunctionType;
182
169
  };
183
170
  };
171
+ export interface FutureEffect {
172
+ label: string;
173
+ type: Type;
174
+ }
184
175
  export type FutureTraitType = TraitType & {
185
176
  isFuture: {
186
177
  outputType: Type;
187
- effects: FunctionImplicitParameter[];
178
+ effect?: FutureEffect;
188
179
  };
189
180
  };
190
181
  export type ConcreteTraitType = TraitType & {
@@ -227,7 +218,6 @@ export interface FunctionType extends Type {
227
218
  tag: TypeTag.Function;
228
219
  parameters: FunctionParameter[];
229
220
  forallParameters: FunctionForallParameter[];
230
- implicitParameters: FunctionImplicitParameter[];
231
221
  variadicParameter?: FunctionParameter;
232
222
  whereClauseExprs?: Expr[];
233
223
  return: FunctionReturn;
@@ -237,6 +227,7 @@ export interface FunctionType extends Type {
237
227
  SelfTraitType?: Type;
238
228
  trait: TraitType;
239
229
  isClosure?: boolean;
230
+ isControl?: boolean;
240
231
  }
241
232
  export interface PtrType extends Type {
242
233
  tag: TypeTag.Ptr;
@@ -1,5 +1,5 @@
1
1
  import { FunctionValue } from "../function-value";
2
- import type { ArrayType, ComptimeListType, ConcreteTraitType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionType, FutureTraitType, IsoType, SourceNamespaceType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, TypeHierarchyType, UnionType, VoidType } from "./definitions";
2
+ import type { ArrayType, ComptimeListType, ConcreteTraitType, DynType, EnumType, FnTraitType, FunctionType, FutureTraitType, IsoType, SourceNamespaceType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, TypeHierarchyType, UnionType, VoidType } from "./definitions";
3
3
  export declare function isPrimitiveType(type: Type): boolean;
4
4
  export declare function isUnitType(type?: Type): boolean;
5
5
  export declare function isComptimeIntType(type?: Type): boolean;
@@ -77,4 +77,3 @@ export declare function isBoxedType(type: Type): type is StructType & {
77
77
  isReferenceSemantics: true;
78
78
  __isBoxed: true;
79
79
  };
80
- export declare function isEffectsRowType(type?: Type): type is EffectsRowType;
@@ -42,6 +42,5 @@ export declare enum TypeTag {
42
42
  Dyn = "Dyn",
43
43
  Expr = "Expr",
44
44
  ComptimeList = "ComptimeList",
45
- EffectsRow = "EffectsRow",
46
45
  TypeApplication = "TypeApplication"
47
46
  }
@@ -7,6 +7,7 @@ export declare function typeProhibitsComptimeModifier(type: Type | undefined, en
7
7
  export declare function isComptimeOnlyType(type: Type, env: Environment): boolean;
8
8
  export declare function isRuntimeOnlyType(type: Type, env: Environment): boolean;
9
9
  export declare function typeContainsRcType(type?: Type, checkedTypes?: Type[]): boolean;
10
+ export declare function typeIsControlBound(type?: Type, checkedTypes?: Type[]): boolean;
10
11
  export declare function typeContainsSomeType(type?: Type, checkedTypes?: Type[]): boolean;
11
12
  export declare function typeContainsUnknownValue(type: Type, visited?: Set<string>): boolean;
12
13
  export declare function getAllSomeTypes(type: Type): Set<SomeType>;