diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b997496..62a4d9dc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Traits can override inherited abstract functions: PR [#724](https://github.com/tact-lang/tact/pull/724) - Fix code generation bug for maps from unsigned integers to Boolean values: PR [#725](https://github.com/tact-lang/tact/pull/725) +- Compiler failure when `toString` gets called as a static function and not a method: PR [#745](https://github.com/tact-lang/tact/pull/745) ## [1.4.4] - 2024-08-18 diff --git a/knip.json b/knip.json index 512ec6fdc..60f411126 100644 --- a/knip.json +++ b/knip.json @@ -10,7 +10,6 @@ "ignoreDependencies": [ "@tact-lang/ton-abi", "@tact-lang/ton-jest", - "@types/jest", - "dist" + "@types/jest" ] } diff --git a/src/check.ts b/src/check.ts index 4d2184c8e..b26b2b912 100644 --- a/src/check.ts +++ b/src/check.ts @@ -30,7 +30,7 @@ export function check(args: { }): CheckResult { // Create context const stdlib = createVirtualFileSystem("@stdlib/", files); - let ctx: CompilerContext = new CompilerContext({ shared: {} }); + let ctx: CompilerContext = new CompilerContext(); ctx = featureEnable(ctx, "debug"); // Enable debug flag (does not affect type checking in practice) ctx = featureEnable(ctx, "masterchain"); // Enable masterchain flag to avoid masterchain-specific errors ctx = featureEnable(ctx, "external"); // Enable external messages flag to avoid external-specific errors diff --git a/src/context.ts b/src/context.ts index 15d1025b9..6af30b795 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,49 +1,42 @@ +type Key = string | number; +export type Store = Map; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type Stores = Map | undefined>; + export class CompilerContext { - readonly shared: Record = {}; + readonly stores: Stores = new Map(); constructor( - args: { shared: Record } = { - shared: {}, + args: { stores: Stores } = { + stores: new Map(), }, ) { - this.shared = args.shared; - Object.freeze(this.shared); + this.stores = args.stores; + Object.freeze(this.stores); Object.freeze(this); } - addShared = (store: symbol, key: string | number, value: T) => { - let sh: Record = {}; - if (this.shared[store]) { - sh = { ...this.shared[store] }; - } - sh[key] = value; - return new CompilerContext({ shared: { ...this.shared, [store]: sh } }); + updateStore = (storeDispatch: symbol, key: Key, value: T) => { + const store: Store = new Map(this.stores.get(storeDispatch) ?? []); + store.set(key, value); + const updatedStores = new Map(this.stores); + updatedStores.set(storeDispatch, store); + return new CompilerContext({ stores: updatedStores }); }; } export function createContextStore() { const symbol = Symbol(); return { - get(ctx: CompilerContext, key: string | number) { - if (!ctx.shared[symbol]) { - return null; - } - const m = ctx.shared[symbol] as Record; - if (m[key]) { - return m[key]; - } else { - return null; - } + get(ctx: CompilerContext, key: Key): T | null { + return ctx.stores.get(symbol)?.get(key) ?? null; }, - all(ctx: CompilerContext): Record { - if (!ctx.shared[symbol]) { - return {} as Record; - } - const m = ctx.shared[symbol] as Record; - return m; + all(ctx: CompilerContext): Store { + return ctx.stores.get(symbol) ?? new Map(); }, - set(ctx: CompilerContext, key: string | number, v: T) { - return ctx.addShared(symbol, key, v); + set(ctx: CompilerContext, key: Key, v: T): CompilerContext { + return ctx.updateStore(symbol, key, v); }, }; } diff --git a/src/generator/createABI.ts b/src/generator/createABI.ts index f4bcb133c..5a083d826 100644 --- a/src/generator/createABI.ts +++ b/src/generator/createABI.ts @@ -8,7 +8,7 @@ import { getAllTypes } from "../types/resolveDescriptors"; import { getAllErrors } from "../types/resolveErrors"; export function createABI(ctx: CompilerContext, name: string): ContractABI { - const allTypes = Object.values(getAllTypes(ctx)); + const allTypes = getAllTypes(ctx); // Contract const contract = allTypes.find((v) => v.name === name); @@ -39,7 +39,7 @@ export function createABI(ctx: CompilerContext, name: string): ContractABI { // // Receivers const receivers: ABIReceiver[] = []; - for (const r of Object.values(contract.receivers)) { + for (const r of contract.receivers) { if (r.selector.kind === "internal-binary") { receivers.push({ receiver: "internal", diff --git a/src/generator/writeProgram.ts b/src/generator/writeProgram.ts index 7262dd674..708fd74a8 100644 --- a/src/generator/writeProgram.ts +++ b/src/generator/writeProgram.ts @@ -299,7 +299,7 @@ function writeAll( abiLink: string, ) { // Load all types - const allTypes = Object.values(getAllTypes(ctx)); + const allTypes = getAllTypes(ctx); const contracts = allTypes.filter((v) => v.kind === "contract"); const c = contracts.find((v) => v.name === name); if (!c) { @@ -377,8 +377,7 @@ function writeAll( } // Static functions - const sf = getAllStaticFunctions(ctx); - Object.values(sf).forEach((f) => { + getAllStaticFunctions(ctx).forEach((f) => { writeFunction(f, wCtx); }); diff --git a/src/generator/writers/writeContract.ts b/src/generator/writers/writeContract.ts index e453b5a98..b09243609 100644 --- a/src/generator/writers/writeContract.ts +++ b/src/generator/writers/writeContract.ts @@ -235,7 +235,7 @@ export function writeMainContract( ctx.append(``); // Write receivers - for (const r of Object.values(type.receivers)) { + for (const r of type.receivers) { writeReceiver(type, r, ctx); } diff --git a/src/generator/writers/writeSerialization.spec.ts b/src/generator/writers/writeSerialization.spec.ts index fe662979a..cafbd3307 100644 --- a/src/generator/writers/writeSerialization.spec.ts +++ b/src/generator/writers/writeSerialization.spec.ts @@ -77,7 +77,7 @@ describe("writeSerialization", () => { "user", wCtx, ); - for (const t of Object.values(getAllTypes(ctx))) { + for (const t of getAllTypes(ctx)) { if (t.kind === "contract" || t.kind === "struct") { writeAccessors(t, "user", wCtx); } diff --git a/src/pipeline/build.ts b/src/pipeline/build.ts index 3206164a7..91d93131a 100644 --- a/src/pipeline/build.ts +++ b/src/pipeline/build.ts @@ -61,7 +61,7 @@ export async function build(args: { const logger: ILogger = args.logger ?? new Logger(); // Configure context - let ctx: CompilerContext = new CompilerContext({ shared: {} }); + let ctx: CompilerContext = new CompilerContext(); const cfg: string = JSON.stringify({ entrypoint: posixNormalize(config.path), options: config.options ?? {}, diff --git a/src/storage/resolveAllocation.ts b/src/storage/resolveAllocation.ts index a611e13ce..86ad78e7b 100644 --- a/src/storage/resolveAllocation.ts +++ b/src/storage/resolveAllocation.ts @@ -1,5 +1,5 @@ import { CompilerContext, createContextStore } from "../context"; -import { getAllTypes, getType, toBounced } from "../types/resolveDescriptors"; +import { getType, toBounced, getAllTypes } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { topologicalSort } from "../utils/utils"; import { StorageAllocation } from "./StorageAllocation"; @@ -12,7 +12,10 @@ import { idText } from "../grammar/ast"; const store = createContextStore(); -export function getAllocation(ctx: CompilerContext, name: string) { +export function getAllocation( + ctx: CompilerContext, + name: string, +): StorageAllocation { const t = store.get(ctx, name); if (!t) { throwInternalCompilerError(`Allocation for ${name} not found`); @@ -20,15 +23,18 @@ export function getAllocation(ctx: CompilerContext, name: string) { return t; } -export function getAllocations(ctx: CompilerContext) { +export function getAllocations(ctx: CompilerContext): { + allocation: StorageAllocation; + type: TypeDescription; +}[] { return getSortedTypes(ctx).map((v) => ({ allocation: getAllocation(ctx, v.name), type: v, })); } -export function getSortedTypes(ctx: CompilerContext) { - const types = Object.values(getAllTypes(ctx)).filter( +export function getSortedTypes(ctx: CompilerContext): TypeDescription[] { + const types = getAllTypes(ctx).filter( (v) => v.kind === "struct" || v.kind === "contract", ); let structs = types.filter((t) => t.kind === "struct"); @@ -54,7 +60,7 @@ export function getSortedTypes(ctx: CompilerContext) { return structs; } -export function resolveAllocations(ctx: CompilerContext) { +export function resolveAllocations(ctx: CompilerContext): CompilerContext { // Load topological order of structs and contracts const types = getSortedTypes(ctx); diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index 2e4274a7a..6cea05332 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -537,21 +537,18 @@ Line 4, col 16: `; exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-default-field 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -560,27 +557,30 @@ exports[`resolveDescriptors should resolve descriptors for const-decl-struct-wit "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -589,17 +589,17 @@ exports[`resolveDescriptors should resolve descriptors for const-decl-struct-wit "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "S": { + { "ast": { "fields": [ { @@ -700,27 +700,24 @@ exports[`resolveDescriptors should resolve descriptors for const-decl-struct-wit "traits": [], "uid": 27286, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-default-field 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-default-field 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-optional-field 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -729,27 +726,30 @@ exports[`resolveDescriptors should resolve descriptors for const-decl-struct-wit "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -758,17 +758,17 @@ exports[`resolveDescriptors should resolve descriptors for const-decl-struct-wit "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "S": { + { "ast": { "fields": [ { @@ -869,14 +869,106 @@ exports[`resolveDescriptors should resolve descriptors for const-decl-struct-wit "traits": [], "uid": 27286, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-optional-field 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-optional-field 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-bounced-slice 1`] = ` -{ - "A": { +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "id": 4, + "kind": "primitive_type_decl", + "loc": primitive Slice;, + "name": { + "id": 3, + "kind": "type_id", + "loc": Slice, + "text": "Slice", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Slice", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 35456, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, + "name": { + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { "ast": { "fields": [ { @@ -980,99 +1072,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-bounced-slic "traits": [], "uid": 22757, }, - "BaseTrait": { - "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, - "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - "Int": { - "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, - "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 38154, - }, - "Slice": { - "ast": { - "id": 4, - "kind": "primitive_type_decl", - "loc": primitive Slice;, - "name": { - "id": 3, - "kind": "type_id", - "loc": Slice, - "text": "Slice", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Slice", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 35456, - }, - "Test": { + { "ast": { "attributes": [], "declarations": [ @@ -1301,14 +1301,106 @@ exports[`resolveDescriptors should resolve descriptors for contract-bounced-slic ], "uid": 44104, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-bounced-slice 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-bounced-slice 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-bounced-too-small-not-detected 1`] = ` -{ - "A": { +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "id": 4, + "kind": "primitive_type_decl", + "loc": primitive Bool;, + "name": { + "id": 3, + "kind": "type_id", + "loc": Bool, + "text": "Bool", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Bool", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 33424, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, + "name": { + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { "ast": { "fields": [ { @@ -1541,99 +1633,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-bounced-too- "traits": [], "uid": 22757, }, - "BaseTrait": { - "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, - "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - "Bool": { - "ast": { - "id": 4, - "kind": "primitive_type_decl", - "loc": primitive Bool;, - "name": { - "id": 3, - "kind": "type_id", - "loc": Bool, - "text": "Bool", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Bool", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 33424, - }, - "Int": { - "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, - "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 38154, - }, - "Test": { + { "ast": { "attributes": [], "declarations": [ @@ -1944,27 +1944,24 @@ exports[`resolveDescriptors should resolve descriptors for contract-bounced-too- ], "uid": 44104, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-bounced-too-small-not-detected 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-bounced-too-small-not-detected 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-const-override-abstract 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -1973,27 +1970,30 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -2002,17 +2002,17 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "T": { + { "ast": { "attributes": [], "declarations": [ @@ -2137,7 +2137,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri ], "uid": 6769, }, - "TestContract": { + { "ast": { "attributes": [], "declarations": [ @@ -2417,27 +2417,24 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri ], "uid": 63070, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-const-override-abstract 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-const-override-abstract 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-const-override-virtual 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -2446,27 +2443,30 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -2475,17 +2475,17 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "T": { + { "ast": { "attributes": [], "declarations": [ @@ -2622,7 +2622,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri ], "uid": 6769, }, - "TestContract": { + { "ast": { "attributes": [], "declarations": [ @@ -2914,14 +2914,77 @@ exports[`resolveDescriptors should resolve descriptors for contract-const-overri ], "uid": 63070, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-const-override-virtual 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-const-override-virtual 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-external-fallback-receiver 1`] = ` -{ - "A": { +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, + }, + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { "ast": { "fields": [ { @@ -3025,70 +3088,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-external-fal "traits": [], "uid": 22757, }, - "BaseTrait": { - "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { - -}, - "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - "Int": { - "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, - "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 38154, - }, - "Test": { + { "ast": { "attributes": [], "declarations": [ @@ -3325,27 +3325,24 @@ exports[`resolveDescriptors should resolve descriptors for contract-external-fal ], "uid": 44104, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-external-fallback-receiver 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-external-fallback-receiver 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-getter-override-abstract 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -3354,27 +3351,30 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -3383,17 +3383,17 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "T": { + { "ast": { "attributes": [], "declarations": [ @@ -3535,7 +3535,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr ], "uid": 6769, }, - "TestContract": { + { "ast": { "attributes": [], "declarations": [ @@ -3863,27 +3863,24 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr ], "uid": 63070, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-getter-override-abstract 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-getter-override-abstract 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for contract-getter-override-virtual 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -3892,27 +3889,30 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -3921,17 +3921,17 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "T": { + { "ast": { "attributes": [], "declarations": [ @@ -4099,7 +4099,7 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr ], "uid": 6769, }, - "TestContract": { + { "ast": { "attributes": [], "declarations": [ @@ -4453,29 +4453,24 @@ exports[`resolveDescriptors should resolve descriptors for contract-getter-overr ], "uid": 63070, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for contract-getter-override-virtual 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for contract-getter-override-virtual 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-uninit-storage-vars 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -4484,17 +4479,17 @@ exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-un "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Bool": { + { "ast": { "id": 4, "kind": "primitive_type_decl", @@ -4523,7 +4518,41 @@ exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-un "traits": [], "uid": 33424, }, - "HelloWorld": { + { + "ast": { + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, + "name": { + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { "ast": { "attributes": [], "declarations": [ @@ -4843,7 +4872,14 @@ exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-un ], "uid": 31498, }, - "Int": { +] +`; + +exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-uninit-storage-vars 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors-in-bodies1 1`] = ` +[ + { "ast": { "id": 2, "kind": "primitive_type_decl", @@ -4872,48 +4908,7 @@ exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-un "traits": [], "uid": 38154, }, -} -`; - -exports[`resolveDescriptors should resolve descriptors for init-vars-analysis-uninit-storage-vars 2`] = `{}`; - -exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors-in-bodies1 1`] = ` -{ - "BaseTrait": { - "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, - "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - "Bool": { + { "ast": { "id": 4, "kind": "primitive_type_decl", @@ -4942,17 +4937,22 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors "traits": [], "uid": 33424, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -4961,22 +4961,22 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, -} +] `; exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors-in-bodies1 2`] = ` -{ - "testFunc": { +[ + { "ast": { "attributes": [], "id": 11, @@ -5027,7 +5027,7 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors }, "self": null, }, - "testFunc2": { + { "ast": { "attributes": [], "id": 15, @@ -5071,7 +5071,7 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors }, "self": null, }, - "testFunc3": { + { "ast": { "attributes": [], "id": 25, @@ -5179,27 +5179,22 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors }, "self": null, }, -} +] `; exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors-in-bodies2 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -5208,17 +5203,17 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Bool": { + { "ast": { "id": 4, "kind": "primitive_type_decl", @@ -5247,36 +5242,134 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors "traits": [], "uid": 33424, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, "name": { - "id": 1, + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { + "ast": { + "fields": [ + { + "as": null, + "id": 10, + "initializer": null, + "kind": "field_decl", + "loc": p: Int, + "name": { + "id": 8, + "kind": "id", + "loc": p, + "text": "p", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + ], + "id": 11, + "kind": "struct_decl", + "loc": struct Point { + p: Int; +}, + "name": { + "id": 7, "kind": "type_id", - "loc": Int, - "text": "Int", + "loc": Point, + "text": "Point", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [ + { + "abi": { + "name": "p", + "type": { + "format": 257, + "kind": "simple", + "optional": false, + "type": "int", + }, + }, + "as": null, + "ast": { + "as": null, + "id": 10, + "initializer": null, + "kind": "field_decl", + "loc": p: Int, + "name": { + "id": 8, + "kind": "id", + "loc": p, + "text": "p", + }, + "type": { + "id": 9, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "default": undefined, + "index": 0, + "loc": p: Int, + "name": "p", + "type": { + "kind": "ref", + "name": "Int", + "optional": false, + }, }, - }, - "constants": [], - "dependsOn": [], - "fields": [], + ], "functions": Map {}, "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "struct", + "name": "Point", "origin": "user", "partialFieldCount": 0, "receivers": [], - "signature": null, - "tlb": null, + "signature": "Point{p:int257}", + "tlb": "_ p:int257 = Point", "traits": [], - "uid": 38154, + "uid": 35778, }, - "Main": { + { "ast": { "attributes": [], "declarations": [ @@ -5737,170 +5830,14 @@ exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors ], "uid": 51099, }, - "Point": { - "ast": { - "fields": [ - { - "as": null, - "id": 10, - "initializer": null, - "kind": "field_decl", - "loc": p: Int, - "name": { - "id": 8, - "kind": "id", - "loc": p, - "text": "p", - }, - "type": { - "id": 9, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - ], - "id": 11, - "kind": "struct_decl", - "loc": struct Point { - p: Int; -}, - "name": { - "id": 7, - "kind": "type_id", - "loc": Point, - "text": "Point", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [ - { - "abi": { - "name": "p", - "type": { - "format": 257, - "kind": "simple", - "optional": false, - "type": "int", - }, - }, - "as": null, - "ast": { - "as": null, - "id": 10, - "initializer": null, - "kind": "field_decl", - "loc": p: Int, - "name": { - "id": 8, - "kind": "id", - "loc": p, - "text": "p", - }, - "type": { - "id": 9, - "kind": "type_id", - "loc": Int, - "text": "Int", - }, - }, - "default": undefined, - "index": 0, - "loc": p: Int, - "name": "p", - "type": { - "kind": "ref", - "name": "Int", - "optional": false, - }, - }, - ], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "struct", - "name": "Point", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": "Point{p:int257}", - "tlb": "_ p:int257 = Point", - "traits": [], - "uid": 35778, - }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors-in-bodies2 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for item-funs-with-errors-in-bodies2 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for item-method 1`] = ` -{ - "BaseTrait": { - "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, - "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - "Bool": { - "ast": { - "id": 4, - "kind": "primitive_type_decl", - "loc": primitive Bool;, - "name": { - "id": 3, - "kind": "type_id", - "loc": Bool, - "text": "Bool", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Bool", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 33424, - }, - "Int": { +[ + { "ast": { "id": 2, "kind": "primitive_type_decl", @@ -6016,14 +5953,36 @@ exports[`resolveDescriptors should resolve descriptors for item-method 1`] = ` "traits": [], "uid": 38154, }, -} -`; - -exports[`resolveDescriptors should resolve descriptors for item-method 2`] = `{}`; - -exports[`resolveDescriptors should resolve descriptors for item-native-decl 1`] = ` -{ - "BaseTrait": { + { + "ast": { + "id": 4, + "kind": "primitive_type_decl", + "loc": primitive Bool;, + "name": { + "id": 3, + "kind": "type_id", + "loc": Bool, + "text": "Bool", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Bool", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 33424, + }, + { "ast": { "attributes": [], "declarations": [], @@ -6055,9 +6014,45 @@ exports[`resolveDescriptors should resolve descriptors for item-native-decl 1`] "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 1020, + }, +] +`; + +exports[`resolveDescriptors should resolve descriptors for item-method 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for item-native-decl 1`] = ` +[ + { + "ast": { + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, + "name": { + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Int", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 38154, }, - "Bool": { + { "ast": { "id": 4, "kind": "primitive_type_decl", @@ -6086,17 +6081,22 @@ exports[`resolveDescriptors should resolve descriptors for item-native-decl 1`] "traits": [], "uid": 33424, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -6105,22 +6105,22 @@ exports[`resolveDescriptors should resolve descriptors for item-native-decl 1`] "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, -} +] `; exports[`resolveDescriptors should resolve descriptors for item-native-decl 2`] = ` -{ - "sample": { +[ + { "ast": { "attributes": [], "id": 13, @@ -6196,75 +6196,12 @@ native sample(a: Int): Int;, }, "self": null, }, -} +] `; exports[`resolveDescriptors should resolve descriptors for item-native-mutating-method 1`] = ` -{ - "BaseTrait": { - "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, - "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", - }, - "traits": [], - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "trait", - "name": "BaseTrait", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 1020, - }, - "Bool": { - "ast": { - "id": 4, - "kind": "primitive_type_decl", - "loc": primitive Bool;, - "name": { - "id": 3, - "kind": "type_id", - "loc": Bool, - "text": "Bool", - }, - }, - "constants": [], - "dependsOn": [], - "fields": [], - "functions": Map {}, - "header": null, - "init": null, - "interfaces": [], - "kind": "primitive_type_decl", - "name": "Bool", - "origin": "user", - "partialFieldCount": 0, - "receivers": [], - "signature": null, - "tlb": null, - "traits": [], - "uid": 33424, - }, - "Int": { +[ + { "ast": { "id": 2, "kind": "primitive_type_decl", @@ -6364,24 +6301,46 @@ mutates extends native inc(self: Int): Int;, "traits": [], "uid": 38154, }, -} -`; - -exports[`resolveDescriptors should resolve descriptors for item-native-mutating-method 2`] = `{}`; - -exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 1`] = ` -{ - "BaseTrait": { + { + "ast": { + "id": 4, + "kind": "primitive_type_decl", + "loc": primitive Bool;, + "name": { + "id": 3, + "kind": "type_id", + "loc": Bool, + "text": "Bool", + }, + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "primitive_type_decl", + "name": "Bool", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 33424, + }, + { "ast": { "attributes": [], "declarations": [], - "id": 4, + "id": 6, "kind": "trait", "loc": trait BaseTrait { }, "name": { - "id": 3, + "id": 5, "kind": "id", "loc": BaseTrait, "text": "BaseTrait", @@ -6405,7 +6364,14 @@ exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 1` "traits": [], "uid": 1020, }, - "Int": { +] +`; + +exports[`resolveDescriptors should resolve descriptors for item-native-mutating-method 2`] = `[]`; + +exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 1`] = ` +[ + { "ast": { "id": 2, "kind": "primitive_type_decl", @@ -6434,7 +6400,41 @@ exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 1` "traits": [], "uid": 38154, }, - "Main": { + { + "ast": { + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { + +}, + "name": { + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", + }, + "traits": [], + }, + "constants": [], + "dependsOn": [], + "fields": [], + "functions": Map {}, + "header": null, + "init": null, + "interfaces": [], + "kind": "trait", + "name": "BaseTrait", + "origin": "user", + "partialFieldCount": 0, + "receivers": [], + "signature": null, + "tlb": null, + "traits": [], + "uid": 1020, + }, + { "ast": { "attributes": [], "declarations": [ @@ -7112,68 +7112,66 @@ exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 1` ], "uid": 51099, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for map-value-as-coins 2`] = `[]`; -exports[`resolveDescriptors should resolve descriptors for scope-loops 1`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for scope-loops 1`] = `[]`; exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` -{ - "scopeIf": { +[ + { "ast": { "attributes": [], - "id": 48, + "id": 12, "kind": "function_def", - "loc": fun scopeIf() { - if (true) { + "loc": fun scopeUntil() { + do { let a: Int = 0; - } + } until (true); let a: String = "abc"; }, "name": { - "id": 37, + "id": 1, "kind": "id", - "loc": scopeIf, - "text": "scopeIf", + "loc": scopeUntil, + "text": "scopeUntil", }, "params": [], "return": null, "statements": [ { "condition": { - "id": 38, + "id": 2, "kind": "boolean", "loc": true, "value": true, }, - "elseif": null, - "falseStatements": null, - "id": 43, - "kind": "statement_condition", - "loc": if (true) { + "id": 7, + "kind": "statement_until", + "loc": do { let a: Int = 0; - }, - "trueStatements": [ + } until (true);, + "statements": [ { "expression": { - "id": 41, + "id": 5, "kind": "number", "loc": 0, "value": 0n, }, - "id": 42, + "id": 6, "kind": "statement_let", "loc": let a: Int = 0;, "name": { - "id": 39, + "id": 3, "kind": "id", "loc": a, "text": "a", }, "type": { - "id": 40, + "id": 4, "kind": "type_id", "loc": Int, "text": "Int", @@ -7183,22 +7181,22 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, { "expression": { - "id": 46, + "id": 10, "kind": "string", "loc": "abc", "value": "abc", }, - "id": 47, + "id": 11, "kind": "statement_let", "loc": let a: String = "abc";, "name": { - "id": 44, + "id": 8, "kind": "id", "loc": a, "text": "a", }, "type": { - "id": 45, + "id": 9, "kind": "type_id", "loc": String, "text": "String", @@ -7212,7 +7210,7 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` "isMutating": false, "isOverride": false, "isVirtual": false, - "name": "scopeIf", + "name": "scopeUntil", "origin": "user", "params": [], "returns": { @@ -7220,7 +7218,7 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, "self": null, }, - "scopeRepeat": { + { "ast": { "attributes": [], "id": 24, @@ -7317,57 +7315,57 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, "self": null, }, - "scopeUntil": { + { "ast": { "attributes": [], - "id": 12, + "id": 36, "kind": "function_def", - "loc": fun scopeUntil() { - do { + "loc": fun scopeWhile() { + while (true) { let a: Int = 0; - } until (true); + } let a: String = "abc"; }, "name": { - "id": 1, + "id": 25, "kind": "id", - "loc": scopeUntil, - "text": "scopeUntil", + "loc": scopeWhile, + "text": "scopeWhile", }, "params": [], "return": null, "statements": [ { "condition": { - "id": 2, + "id": 26, "kind": "boolean", "loc": true, "value": true, }, - "id": 7, - "kind": "statement_until", - "loc": do { + "id": 31, + "kind": "statement_while", + "loc": while (true) { let a: Int = 0; - } until (true);, + }, "statements": [ { "expression": { - "id": 5, + "id": 29, "kind": "number", "loc": 0, "value": 0n, }, - "id": 6, + "id": 30, "kind": "statement_let", "loc": let a: Int = 0;, "name": { - "id": 3, + "id": 27, "kind": "id", "loc": a, "text": "a", }, "type": { - "id": 4, + "id": 28, "kind": "type_id", "loc": Int, "text": "Int", @@ -7377,22 +7375,22 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, { "expression": { - "id": 10, + "id": 34, "kind": "string", "loc": "abc", "value": "abc", }, - "id": 11, + "id": 35, "kind": "statement_let", "loc": let a: String = "abc";, "name": { - "id": 8, + "id": 32, "kind": "id", "loc": a, "text": "a", }, "type": { - "id": 9, + "id": 33, "kind": "type_id", "loc": String, "text": "String", @@ -7406,7 +7404,7 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` "isMutating": false, "isOverride": false, "isVirtual": false, - "name": "scopeUntil", + "name": "scopeWhile", "origin": "user", "params": [], "returns": { @@ -7414,57 +7412,59 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, "self": null, }, - "scopeWhile": { + { "ast": { "attributes": [], - "id": 36, + "id": 48, "kind": "function_def", - "loc": fun scopeWhile() { - while (true) { + "loc": fun scopeIf() { + if (true) { let a: Int = 0; } let a: String = "abc"; }, "name": { - "id": 25, + "id": 37, "kind": "id", - "loc": scopeWhile, - "text": "scopeWhile", + "loc": scopeIf, + "text": "scopeIf", }, "params": [], "return": null, "statements": [ { "condition": { - "id": 26, + "id": 38, "kind": "boolean", "loc": true, "value": true, }, - "id": 31, - "kind": "statement_while", - "loc": while (true) { + "elseif": null, + "falseStatements": null, + "id": 43, + "kind": "statement_condition", + "loc": if (true) { let a: Int = 0; }, - "statements": [ + "trueStatements": [ { "expression": { - "id": 29, + "id": 41, "kind": "number", "loc": 0, "value": 0n, }, - "id": 30, + "id": 42, "kind": "statement_let", "loc": let a: Int = 0;, "name": { - "id": 27, + "id": 39, "kind": "id", "loc": a, "text": "a", }, "type": { - "id": 28, + "id": 40, "kind": "type_id", "loc": Int, "text": "Int", @@ -7474,22 +7474,22 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, { "expression": { - "id": 34, + "id": 46, "kind": "string", "loc": "abc", "value": "abc", }, - "id": 35, + "id": 47, "kind": "statement_let", "loc": let a: String = "abc";, "name": { - "id": 32, + "id": 44, "kind": "id", "loc": a, "text": "a", }, "type": { - "id": 33, + "id": 45, "kind": "type_id", "loc": String, "text": "String", @@ -7503,7 +7503,7 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` "isMutating": false, "isOverride": false, "isVirtual": false, - "name": "scopeWhile", + "name": "scopeIf", "origin": "user", "params": [], "returns": { @@ -7511,25 +7511,22 @@ exports[`resolveDescriptors should resolve descriptors for scope-loops 2`] = ` }, "self": null, }, -} +] `; exports[`resolveDescriptors should resolve descriptors for struct-decl-default-field 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -7538,27 +7535,30 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-default-f "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -7567,17 +7567,17 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-default-f "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "S": { + { "ast": { "fields": [ { @@ -7678,29 +7678,24 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-default-f "traits": [], "uid": 27286, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for struct-decl-default-field 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for struct-decl-default-field 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -7709,17 +7704,17 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 1` "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Bool": { + { "ast": { "id": 4, "kind": "primitive_type_decl", @@ -7748,17 +7743,22 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 1` "traits": [], "uid": 33424, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -7767,17 +7767,17 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 1` "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "Struct1": { + { "ast": { "fields": [ { @@ -7929,7 +7929,7 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 1` "traits": [], "uid": 63177, }, - "Struct2": { + { "ast": { "fields": [ { @@ -8021,27 +8021,24 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 1` "traits": [], "uid": 50858, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for struct-decl-nested 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-types 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 4, - "kind": "trait", - "loc": trait BaseTrait { }, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 3, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -8050,27 +8047,30 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-t "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 4, + "kind": "trait", + "loc": trait BaseTrait { }, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 3, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -8079,17 +8079,17 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-t "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, - "SetIntMap4": { + { "ast": { "fields": [ { @@ -8252,7 +8252,7 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-t "traits": [], "uid": 24351, }, - "SomeStruct": { + { "ast": { "fields": [ { @@ -8343,14 +8343,14 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-t "traits": [], "uid": 61480, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-types 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for struct-decl-non-rec-types 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { "attributes": [], "declarations": [], @@ -8382,16 +8382,16 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder "traits": [], "uid": 1020, }, - "Cell": { + { "ast": { - "id": 6, + "id": 4, "kind": "primitive_type_decl", - "loc": primitive Cell;, + "loc": primitive Int;, "name": { - "id": 5, + "id": 3, "kind": "type_id", - "loc": Cell, - "text": "Cell", + "loc": Int, + "text": "Int", }, }, "constants": [], @@ -8402,25 +8402,25 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder "init": null, "interfaces": [], "kind": "primitive_type_decl", - "name": "Cell", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 26294, + "uid": 38154, }, - "Int": { + { "ast": { - "id": 4, + "id": 6, "kind": "primitive_type_decl", - "loc": primitive Int;, + "loc": primitive Cell;, "name": { - "id": 3, + "id": 5, "kind": "type_id", - "loc": Int, - "text": "Int", + "loc": Cell, + "text": "Cell", }, }, "constants": [], @@ -8431,16 +8431,16 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder "init": null, "interfaces": [], "kind": "primitive_type_decl", - "name": "Int", + "name": "Cell", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 26294, }, - "Test": { + { "ast": { "fields": [ { @@ -8663,29 +8663,24 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder "traits": [], "uid": 44104, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder 2`] = `[]`; exports[`resolveDescriptors should resolve descriptors for trait-base 1`] = ` -{ - "BaseTrait": { +[ + { "ast": { - "attributes": [], - "declarations": [], - "id": 6, - "kind": "trait", - "loc": trait BaseTrait { - -}, + "id": 2, + "kind": "primitive_type_decl", + "loc": primitive Int;, "name": { - "id": 5, - "kind": "id", - "loc": BaseTrait, - "text": "BaseTrait", + "id": 1, + "kind": "type_id", + "loc": Int, + "text": "Int", }, - "traits": [], }, "constants": [], "dependsOn": [], @@ -8694,17 +8689,17 @@ exports[`resolveDescriptors should resolve descriptors for trait-base 1`] = ` "header": null, "init": null, "interfaces": [], - "kind": "trait", - "name": "BaseTrait", + "kind": "primitive_type_decl", + "name": "Int", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 1020, + "uid": 38154, }, - "Bool": { + { "ast": { "id": 4, "kind": "primitive_type_decl", @@ -8733,17 +8728,22 @@ exports[`resolveDescriptors should resolve descriptors for trait-base 1`] = ` "traits": [], "uid": 33424, }, - "Int": { + { "ast": { - "id": 2, - "kind": "primitive_type_decl", - "loc": primitive Int;, + "attributes": [], + "declarations": [], + "id": 6, + "kind": "trait", + "loc": trait BaseTrait { + +}, "name": { - "id": 1, - "kind": "type_id", - "loc": Int, - "text": "Int", + "id": 5, + "kind": "id", + "loc": BaseTrait, + "text": "BaseTrait", }, + "traits": [], }, "constants": [], "dependsOn": [], @@ -8752,17 +8752,17 @@ exports[`resolveDescriptors should resolve descriptors for trait-base 1`] = ` "header": null, "init": null, "interfaces": [], - "kind": "primitive_type_decl", - "name": "Int", + "kind": "trait", + "name": "BaseTrait", "origin": "user", "partialFieldCount": 0, "receivers": [], "signature": null, "tlb": null, "traits": [], - "uid": 38154, + "uid": 1020, }, -} +] `; -exports[`resolveDescriptors should resolve descriptors for trait-base 2`] = `{}`; +exports[`resolveDescriptors should resolve descriptors for trait-base 2`] = `[]`; diff --git a/src/types/__snapshots__/resolveStatements.spec.ts.snap b/src/types/__snapshots__/resolveStatements.spec.ts.snap index 18dde58f3..78e71078d 100644 --- a/src/types/__snapshots__/resolveStatements.spec.ts.snap +++ b/src/types/__snapshots__/resolveStatements.spec.ts.snap @@ -1335,7 +1335,7 @@ Line 5, col 14: " `; -exports[`resolveStatements should fail statements for var-scope-no-toString-global-fun 1`] = ` +exports[`resolveStatements should fail statements for var-scope-no-toString-global-fun1 1`] = ` ":7:9: Static function "toString" does not exist Line 7, col 9: 6 | init() { @@ -1345,6 +1345,26 @@ Line 7, col 9: " `; +exports[`resolveStatements should fail statements for var-scope-no-toString-global-fun2 1`] = ` +":6:12: Static function "toString" does not exist. Perhaps you meant to call ".toString(...)" extension function? +Line 6, col 12: + 5 | extends fun toString(self: WrappedInt): Int { +> 6 | return toString(self.x); + ^~~~~~~~~~~~~~~~ + 7 | } +" +`; + +exports[`resolveStatements should fail statements for var-scope-no-valueOf-global-fun 1`] = ` +":4:5: Static function "valueOf" does not exist +Line 4, col 5: + 3 | fun foo(x: Int) { +> 4 | valueOf(x); + ^~~~~~~~~~ + 5 | } +" +`; + exports[`resolveStatements should fail statements for var-scope-rec-fun-shadowing-catch 1`] = ` ":6:14: Variable cannot have the same name as its enclosing function: "rec" Line 6, col 14: @@ -1499,10 +1519,6 @@ exports[`resolveStatements should resolve statements for assign-self-mutating-me [ [ "self", - "IntWrapper", - ], - [ - "self.x", "Int", ], [ @@ -1511,6 +1527,10 @@ exports[`resolveStatements should resolve statements for assign-self-mutating-me ], [ "self", + "IntWrapper", + ], + [ + "self.x", "Int", ], [ diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index 18bcd29d6..df305139b 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -24,7 +24,7 @@ import { throwCompilationError, throwInternalCompilerError, } from "../errors"; -import { CompilerContext, createContextStore } from "../context"; +import { CompilerContext, Store, createContextStore } from "../context"; import { ConstantDescription, FieldDescription, @@ -1823,12 +1823,16 @@ export function getType( return r; } -export function getAllTypes(ctx: CompilerContext) { +function getTypeStore(ctx: CompilerContext): Store { return store.all(ctx); } -export function getContracts(ctx: CompilerContext) { - return Object.values(getAllTypes(ctx)) +export function getAllTypes(ctx: CompilerContext): TypeDescription[] { + return Array.from(getTypeStore(ctx).values()); +} + +export function getContracts(ctx: CompilerContext): string[] { + return getAllTypes(ctx) .filter((v) => v.kind === "contract") .map((v) => v.name); } @@ -1863,14 +1867,30 @@ export function hasStaticConstant(ctx: CompilerContext, name: string) { return !!staticConstantsStore.get(ctx, name); } -export function getAllStaticFunctions(ctx: CompilerContext) { +function getStaticFunctionStore( + ctx: CompilerContext, +): Store { return staticFunctionsStore.all(ctx); } -export function getAllStaticConstants(ctx: CompilerContext) { +export function getAllStaticFunctions( + ctx: CompilerContext, +): FunctionDescription[] { + return Array.from(getStaticFunctionStore(ctx).values()); +} + +function getStaticConstantStore( + ctx: CompilerContext, +): Store { return staticConstantsStore.all(ctx); } +export function getAllStaticConstants( + ctx: CompilerContext, +): ConstantDescription[] { + return Array.from(getStaticConstantStore(ctx).values()); +} + function resolvePartialFields(ctx: CompilerContext, type: TypeDescription) { if (type.kind !== "struct") return 0; @@ -1953,7 +1973,7 @@ function initializeConstants( function initializeConstantsAndDefaultContractAndStructFields( ctx: CompilerContext, ): CompilerContext { - for (const aggregateTy of Object.values(getAllTypes(ctx))) { + for (const aggregateTy of getAllTypes(ctx)) { switch (aggregateTy.kind) { case "primitive_type_decl": break; @@ -1997,8 +2017,7 @@ function initializeConstantsAndDefaultContractAndStructFields( // constants need to be processed after structs because // constants might use default field values: `const x: Int = S{}.f`, where `struct S {f: Int = 42}` // and the default field values are filled in during struct field initializers processing - const staticConstants = Object.values(getAllStaticConstants(ctx)); - ctx = initializeConstants(staticConstants, ctx); + ctx = initializeConstants(getAllStaticConstants(ctx), ctx); return ctx; } @@ -2009,7 +2028,7 @@ function checkRecursiveTypes(ctx: CompilerContext): void { // and terminates early if a non-trivial SCC is detected // https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm - const structs = Object.values(getAllTypes(ctx)).filter( + const structs = getAllTypes(ctx).filter( (aggregate) => aggregate.kind === "struct", ); let index = 0; diff --git a/src/types/resolveErrors.ts b/src/types/resolveErrors.ts index 1552ab6cc..29e3e00d3 100644 --- a/src/types/resolveErrors.ts +++ b/src/types/resolveErrors.ts @@ -5,12 +5,14 @@ import { traverse } from "../grammar/iterators"; import { evalConstantExpression } from "../constEval"; import { throwInternalCompilerError } from "../errors"; import { - getAllStaticConstants, getAllStaticFunctions, getAllTypes, + getAllStaticConstants, } from "./resolveDescriptors"; -const exceptions = createContextStore<{ value: string; id: number }>(); +type Exception = { value: string; id: number }; + +const exceptions = createContextStore(); function stringId(src: string): number { return sha256_sync(src).readUInt32BE(0); @@ -33,7 +35,9 @@ function resolveStringsInAST(ast: AstNode, ctx: CompilerContext) { if (!exceptions.get(ctx, resolved)) { const id = exceptionId(resolved); if ( - Object.values(exceptions.all(ctx)).find((v) => v.id === id) + Array.from(exceptions.all(ctx).values()).find( + (v) => v.id === id, + ) ) { throwInternalCompilerError( `Duplicate error id: "${resolved}"`, @@ -48,24 +52,24 @@ function resolveStringsInAST(ast: AstNode, ctx: CompilerContext) { export function resolveErrors(ctx: CompilerContext) { // Process all static functions - for (const f of Object.values(getAllStaticFunctions(ctx))) { + for (const f of getAllStaticFunctions(ctx)) { ctx = resolveStringsInAST(f.ast, ctx); } // Process all static constants - for (const f of Object.values(getAllStaticConstants(ctx))) { + for (const f of getAllStaticConstants(ctx)) { ctx = resolveStringsInAST(f.ast, ctx); } // Process all types - for (const t of Object.values(getAllTypes(ctx))) { + for (const t of getAllTypes(ctx)) { // Process fields - for (const f of Object.values(t.fields)) { + for (const f of t.fields) { ctx = resolveStringsInAST(f.ast, ctx); } // Process constants - for (const f of Object.values(t.constants)) { + for (const f of t.constants) { ctx = resolveStringsInAST(f.ast, ctx); } @@ -75,7 +79,7 @@ export function resolveErrors(ctx: CompilerContext) { } // Process receivers - for (const f of Object.values(t.receivers)) { + for (const f of t.receivers) { ctx = resolveStringsInAST(f.ast, ctx); } @@ -88,8 +92,8 @@ export function resolveErrors(ctx: CompilerContext) { return ctx; } -export function getAllErrors(ctx: CompilerContext) { - return Object.values(exceptions.all(ctx)); +export function getAllErrors(ctx: CompilerContext): Exception[] { + return Array.from(exceptions.all(ctx).values()); } export function getErrorId(value: string, ctx: CompilerContext) { diff --git a/src/types/resolveExpression.ts b/src/types/resolveExpression.ts index 5f39b3e45..95190249c 100644 --- a/src/types/resolveExpression.ts +++ b/src/types/resolveExpression.ts @@ -19,6 +19,7 @@ import { import { idTextErr, throwCompilationError } from "../errors"; import { CompilerContext, createContextStore } from "../context"; import { + getAllTypes, getStaticConstant, getStaticFunction, getType, @@ -486,6 +487,18 @@ function resolveStaticCall( // Check if function exists if (!hasStaticFunction(ctx, idText(exp.function))) { + // check if there is a method with the same name + if ( + getAllTypes(ctx).find( + (ty) => ty.functions.get(idText(exp.function)) !== undefined, + ) !== undefined + ) { + throwCompilationError( + `Static function ${idTextErr(exp.function)} does not exist. Perhaps you meant to call ".${idText(exp.function)}(...)" extension function?`, + exp.loc, + ); + } + throwCompilationError( `Static function ${idTextErr(exp.function)} does not exist`, exp.loc, @@ -830,7 +843,7 @@ export function resolveExpression( export function getAllExpressionTypes(ctx: CompilerContext) { const res: [string, string][] = []; - Object.values(store.all(ctx)).forEach((val) => { + store.all(ctx).forEach((val, _key) => { res.push([val.ast.loc.contents, printTypeRef(val.description)]); }); return res; diff --git a/src/types/resolveSignatures.ts b/src/types/resolveSignatures.ts index 083ef8653..6e8d49020 100644 --- a/src/types/resolveSignatures.ts +++ b/src/types/resolveSignatures.ts @@ -4,7 +4,7 @@ import { CompilerContext } from "../context"; import { idToHex } from "../utils/idToHex"; import { newMessageId } from "../utils/newMessageId"; import { throwInternalCompilerError } from "../errors"; -import { getAllTypes, getType } from "./resolveDescriptors"; +import { getType, getAllTypes } from "./resolveDescriptors"; import { BinaryReceiverSelector, CommentReceiverSelector, @@ -15,7 +15,6 @@ import { AstReceiver } from "../grammar/ast"; import { commentPseudoOpcode } from "../generator/writers/writeRouter"; export function resolveSignatures(ctx: CompilerContext) { - const types = getAllTypes(ctx); const signatures: Map< string, { signature: string; tlb: string; id: number | null } @@ -197,7 +196,7 @@ export function resolveSignatures(ctx: CompilerContext) { return { signature, id, tlb }; } - Object.values(types).forEach((t) => { + getAllTypes(ctx).forEach((t) => { if (t.kind === "struct") { const r = createTupleSignature(t.name); t.tlb = r.tlb; @@ -311,8 +310,7 @@ function checkMessageOpcodesUniqueInContractOrTrait( } function checkMessageOpcodesUnique(ctx: CompilerContext) { - const allTypes = getAllTypes(ctx); - Object.values(allTypes).forEach((aggregate) => { + getAllTypes(ctx).forEach((aggregate) => { switch (aggregate.kind) { case "contract": case "trait": diff --git a/src/types/resolveStatements.ts b/src/types/resolveStatements.ts index 59b5fb9a9..4a9b9e7f2 100644 --- a/src/types/resolveStatements.ts +++ b/src/types/resolveStatements.ts @@ -19,11 +19,11 @@ import { } from "../errors"; import { getAllStaticFunctions, - getAllTypes, getStaticConstant, getType, hasStaticConstant, resolveTypeRef, + getAllTypes, } from "./resolveDescriptors"; import { getExpType, resolveExpression } from "./resolveExpression"; import { printTypeRef, TypeRef } from "./types"; @@ -691,7 +691,7 @@ function processFunctionBody( export function resolveStatements(ctx: CompilerContext) { // Process all static functions - for (const f of Object.values(getAllStaticFunctions(ctx))) { + for (const f of getAllStaticFunctions(ctx)) { if (f.ast.kind === "function_def") { // Build statement context let sctx = emptyContext(f.ast.loc, f.name, f.returns); @@ -704,7 +704,7 @@ export function resolveStatements(ctx: CompilerContext) { } // Process all types - for (const t of Object.values(getAllTypes(ctx))) { + for (const t of getAllTypes(ctx)) { // Process init if (t.init) { // Build statement context @@ -740,7 +740,7 @@ export function resolveStatements(ctx: CompilerContext) { } // Process receivers - for (const f of Object.values(t.receivers)) { + for (const f of t.receivers) { // Build statement context let sctx = emptyContext(f.ast.loc, null, { kind: "void" }); sctx = addVariable( diff --git a/src/types/stmts-failed/var-scope-no-toString-global-fun.tact b/src/types/stmts-failed/var-scope-no-toString-global-fun1.tact similarity index 100% rename from src/types/stmts-failed/var-scope-no-toString-global-fun.tact rename to src/types/stmts-failed/var-scope-no-toString-global-fun1.tact diff --git a/src/types/stmts-failed/var-scope-no-toString-global-fun2.tact b/src/types/stmts-failed/var-scope-no-toString-global-fun2.tact new file mode 100644 index 000000000..8c2e8439a --- /dev/null +++ b/src/types/stmts-failed/var-scope-no-toString-global-fun2.tact @@ -0,0 +1,8 @@ +primitive Int; + +struct WrappedInt { x: Int } + +extends fun toString(self: WrappedInt): Int { + return toString(self.x); +} + diff --git a/src/types/stmts-failed/var-scope-no-valueOf-global-fun.tact b/src/types/stmts-failed/var-scope-no-valueOf-global-fun.tact new file mode 100644 index 000000000..8dc346c02 --- /dev/null +++ b/src/types/stmts-failed/var-scope-no-valueOf-global-fun.tact @@ -0,0 +1,5 @@ +primitive Int; + +fun foo(x: Int) { + valueOf(x); +}