diff --git a/dev-docs/CHANGELOG.md b/dev-docs/CHANGELOG.md index 3237f1ac5..ef960bca0 100644 --- a/dev-docs/CHANGELOG.md +++ b/dev-docs/CHANGELOG.md @@ -83,6 +83,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support overriding constants and methods of BaseTrait: PR [#1591](https://github.com/tact-lang/tact/pull/1591) - Forbid traits inherit implicitly from BaseTrait: PR [#1591](https://github.com/tact-lang/tact/pull/1591) - Forbid the `override` modifier for constants without the corresponding super-constant: PR [#1591](https://github.com/tact-lang/tact/pull/1591) +- Remove "remainder" from error messages and TL-B schemes: PR [#1699](https://github.com/tact-lang/tact/pull/1699) ### Docs diff --git a/docs/src/content/docs/book/cells.mdx b/docs/src/content/docs/book/cells.mdx index eb8f99504..ea0e7c76c 100644 --- a/docs/src/content/docs/book/cells.mdx +++ b/docs/src/content/docs/book/cells.mdx @@ -159,12 +159,12 @@ struct TwoCell { struct TwoBuilder { bRef: Builder; // ^builder in TL-B - bRem: Builder as remaining; // builder in TL-B + bRem: Builder as remaining; // cell in TL-B } struct TwoSlice { sRef: Slice; // ^slice in TL-B - sRem: Slice as remaining; // slice in TL-B + sRem: Slice as remaining; // cell in TL-B } contract SerializationExample { diff --git a/docs/src/content/docs/zh-cn/book/cells.mdx b/docs/src/content/docs/zh-cn/book/cells.mdx index a5fafbd0a..38306b6a5 100644 --- a/docs/src/content/docs/zh-cn/book/cells.mdx +++ b/docs/src/content/docs/zh-cn/book/cells.mdx @@ -55,7 +55,7 @@ description: Cells、Builders 和 Slices 是 TON 区块链的底层单元 标准 [`Cell{:tact}`](#cells) 表示法是 [tvm.pdf](https://docs.ton.org/tvm.pdf) 中首次描述的 cells 通用序列化格式。 它的算法以八进制(字节)序列表示cell,首先将称为描述符的第一个 $2$ 字节序列化: -- _引用描述符_(Refs descriptor)根据以下公式计算:$r + 8 _ k + 32 _ l$,其中 $r$ 是 cell 中包含的引用数量(介于 $0$ 和 $4$ 之间),$k$ 是 cell 类型的标志($0$ 表示[普通](#cells-kinds),$1$ 表示[特殊](#cells-kinds)),$l$ 是 +- _引用描述符_(Refs descriptor)根据以下公式计算:$r + 8 _ k + 32 _ l$,其中 $r$ 是 cell 中包含的引用数量(介于 $0$ 和 $4$ 之间),$k$ 是 cell 类型的标志($0$ 表示[普通](#cells-kinds),$1$ 表示[特殊](#cells-kinds)),$l$ 是 cell 的[层级](#cells-levels)(介于 $0$ 和 $3$ 之间)。 - _位描述符_(Bits descriptor)根据以下公式计算:$\lfloor\frac{b}{8}\rfloor + \lceil\frac{b}{8}\rceil$,其中 $b$ 是 cell 中的位数(介于 $0$ 和 $1023$ 之间)。 @@ -159,9 +159,9 @@ contract SerializationExample { sRef: Slice; // ^slice in TL-B // With `remaining` - cRem: Cell as remaining; // remainder in TL-B - bRem: Builder as remaining; // remainder in TL-B - sRem: Slice as remaining; // remainder in TL-B + cRem: Cell as remaining; // cell in TL-B + bRem: Builder as remaining; // cell in TL-B + sRem: Slice as remaining; // cell in TL-B // Constructor function, // necessary for this example contract to compile diff --git a/src/storage/allocator.ts b/src/storage/allocator.ts index 2d388073e..4dcc2cce0 100644 --- a/src/storage/allocator.ts +++ b/src/storage/allocator.ts @@ -43,7 +43,7 @@ function getOperationSize(src: AllocationOperationType): { case "remainder": { if (src.optional) { throwInternalCompilerError( - "Remainder cell cannot be optional", + `"as remaining" cell cannot be optional`, ); } return { bits: 0, refs: 0 }; diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index 133d6e95a..d458720e9 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -145,7 +145,7 @@ exports[`resolveDescriptors should fail descriptors for contract-const-override- `; exports[`resolveDescriptors should fail descriptors for contract-decl-remainder-in-the-middle 1`] = ` -":8:5: The "remainder" field can only be the last field of the contract +":8:5: The "as remaining" field can only be the last field of the contract 7 | a: Int = 0; > 8 | s: Cell as remaining; ^~~~~~~~~~~~~~~~~~~~ @@ -402,7 +402,7 @@ exports[`resolveDescriptors should fail descriptors for init-self-reassign-in-if `; exports[`resolveDescriptors should fail descriptors for message-decl-remainder-in-the-middle 1`] = ` -":8:5: The "remainder" field can only be the last field of the message +":8:5: The "as remaining" field can only be the last field of the message 7 | a: Int; > 8 | s: Cell as remaining; ^~~~~~~~~~~~~~~~~~~~ @@ -826,7 +826,7 @@ exports[`resolveDescriptors should fail descriptors for struct-decl-mutually-rec `; exports[`resolveDescriptors should fail descriptors for struct-decl-remainder-in-the-middle 1`] = ` -":8:5: The "remainder" field can only be the last field of the struct +":8:5: The "as remaining" field can only be the last field of the struct 7 | a: Int; > 8 | s: Cell as remaining; ^~~~~~~~~~~~~~~~~~~~ @@ -13332,7 +13332,7 @@ exports[`resolveDescriptors should resolve descriptors for message-decl-remainde "id": 0, "kind": "number", "loc": , - "value": 3344478825n, + "value": 1872381133n, }, "init": null, "interfaces": [], @@ -13341,8 +13341,8 @@ exports[`resolveDescriptors should resolve descriptors for message-decl-remainde "origin": "user", "partialFieldCount": 0, "receivers": [], - "signature": "Test{a:int257,b:int257,s:remainder}", - "tlb": "test#c758b269 a:int257 b:int257 s:remainder = Test", + "signature": "Test{a:int257,b:int257,s:cell}", + "tlb": "test#6f9a44cd a:int257 b:int257 s:cell = Test", "traits": [], "uid": 44104, }, @@ -29723,8 +29723,8 @@ exports[`resolveDescriptors should resolve descriptors for struct-decl-remainder "origin": "user", "partialFieldCount": 0, "receivers": [], - "signature": "Test{a:int257,b:int257,s:remainder}", - "tlb": "_ a:int257 b:int257 s:remainder = Test", + "signature": "Test{a:int257,b:int257,s:cell}", + "tlb": "_ a:int257 b:int257 s:cell = Test", "traits": [], "uid": 44104, }, diff --git a/src/types/resolveSignatures.ts b/src/types/resolveSignatures.ts index 85e53b214..dcdd79669 100644 --- a/src/types/resolveSignatures.ts +++ b/src/types/resolveSignatures.ts @@ -73,7 +73,7 @@ export function resolveSignatures(ctx: CompilerContext, Ast: FactoryAst) { return "address"; } else if (type === "cell") { if (format === "remainder") { - return "remainder"; + return "cell"; } else if (format === "ref") { return "^cell"; } @@ -85,7 +85,7 @@ export function resolveSignatures(ctx: CompilerContext, Ast: FactoryAst) { return "^cell"; } else if (type === "slice") { if (format === "remainder") { - return "remainder"; + return "cell"; } else if (format === "ref") { return "^slice"; } else if (format !== null) { @@ -96,7 +96,7 @@ export function resolveSignatures(ctx: CompilerContext, Ast: FactoryAst) { return "^slice"; } else if (type === "builder") { if (format === "remainder") { - return "remainder"; + return "cell"; } else if (format === "ref") { return "^slice"; } else if (format !== null) { @@ -186,13 +186,13 @@ export function resolveSignatures(ctx: CompilerContext, Ast: FactoryAst) { throwInternalCompilerError(`Unsupported type: ${name}`); } - // Check for no "remainder" in the middle of the struct + // Check for no "as remaining" in the middle of the struct for (const field of t.fields.slice(0, -1)) { if (field.as === "remaining") { const kind = t.ast.kind === "message_decl" ? "message" : "struct"; throwCompilationError( - `The "remainder" field can only be the last field of the ${kind}`, + `The "as remaining" field can only be the last field of the ${kind}`, field.loc, ); } @@ -416,7 +416,7 @@ function checkContractFields(t: TypeDescription) { for (const field of t.fields.slice(0, -1)) { if (field.as === "remaining") { throwCompilationError( - `The "remainder" field can only be the last field of the contract`, + `The "as remaining" field can only be the last field of the contract`, field.ast.loc, ); }