1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

[Tolk] Allow cell and slice be valid identifiers

They are not keywords anymore.
> var cell = ...;
> var cell: cell = ...;
Motivation: in the future, when structures are implemented, this obviously should be valid:
> struct a { ... }
> var a = ...;
Struct fields will also be allowed to have names int/slice/cell.
This commit is contained in:
tolk-vm 2025-01-27 10:33:24 +03:00
parent 7a1602f591
commit 5b44e01455
No known key found for this signature in database
GPG key ID: 7905DD7FE0324B12
9 changed files with 47 additions and 69 deletions

View file

@ -14,6 +14,18 @@ fun autoInferIntNull(x: int) {
return x;
}
fun typesAsIdentifiers(builder: builder) {
var int = 1;
var cell = builder.endCell();
var slice = cell.beginParse();
{
var cell: cell = cell;
var tuple: tuple = createEmptyTuple();
var bool: bool = tuple.tupleAt<int>(0) > 0;
}
return int;
}
fun main(value: int) {
var (x: int, y) = (autoInferIntNull(value), autoInferIntNull(value * 2));
if (x == null && y == null) { return null; }

View file

@ -1,12 +1,12 @@
fun main() {
try {
} catch(int, arg) {}
} catch(if, arg) {}
return 0;
}
/**
@compilation_should_fail
@stderr expected identifier, got `int`
@stderr catch(int
@stderr expected identifier, got `if`
@stderr catch(if
*/

View file

@ -4,5 +4,5 @@ fun main(int): int {
/**
@compilation_should_fail
@stderr expected parameter name, got `int`
@stderr expected `: <parameter_type>`, got `)`
*/

View file

@ -4,5 +4,5 @@ fun main() {
/**
@compilation_should_fail
@stderr probably, you use FunC-like declarations; valid syntax is `var x: int = ...`
@stderr expected `;`, got `x`
*/

View file

@ -4,6 +4,8 @@ fun foo1(): int { return 111; }
fun foo2(): int { return 222; }
@method_id(10)
fun foo3(): int { return 333; }
@method_id(11)
fun slice(slice: slice): slice { return slice; }
fun main(): int { return 999; }
/**