Skip to content

Commit

Permalink
fix: replace remainder in error messages with as remaining (#1699)
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 authored Feb 8, 2025
1 parent d30ec9c commit ca6e7d2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions dev-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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: PR [#1699](https://github.com/tact-lang/tact/pull/1699)

### Docs

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/zh-cn/book/cells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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$ 之间)。

Expand Down
2 changes: 1 addition & 1 deletion src/storage/allocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
6 changes: 3 additions & 3 deletions src/types/__snapshots__/resolveDescriptors.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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`] = `
"<unknown>:8:5: The "remainder" field can only be the last field of the contract
"<unknown>:8:5: The "as remaining" field can only be the last field of the contract
7 | a: Int = 0;
> 8 | s: Cell as remaining;
^~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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`] = `
"<unknown>:8:5: The "remainder" field can only be the last field of the message
"<unknown>:8:5: The "as remaining" field can only be the last field of the message
7 | a: Int;
> 8 | s: Cell as remaining;
^~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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`] = `
"<unknown>:8:5: The "remainder" field can only be the last field of the struct
"<unknown>:8:5: The "as remaining" field can only be the last field of the struct
7 | a: Int;
> 8 | s: Cell as remaining;
^~~~~~~~~~~~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions src/types/resolveSignatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down Expand Up @@ -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,
);
}
Expand Down

0 comments on commit ca6e7d2

Please sign in to comment.