From 7f192a6aa4700c9876e7598c5724e6fa50d9c39e Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:01:33 +0200 Subject: [PATCH] fix: improve `funcId` recognition and squash misdetection bugs (#636) Co-authored-by: Anton Trunov --- CHANGELOG.md | 2 + .../__snapshots__/grammar.spec.ts.snap | 641 +++++++++++++++++- src/grammar/grammar.ohm | 30 +- .../funcid-native-fun-arith-operator.tact | 2 + .../funcid-native-fun-assign-operator.tact | 2 + .../funcid-native-fun-bitwise-operator.tact | 2 + ...funcid-native-fun-comparison-operator.tact | 2 + .../funcid-native-fun-control-keyword.tact | 2 + .../funcid-native-fun-delimiter.tact | 2 + .../funcid-native-fun-directive.tact | 2 + .../funcid-native-fun-keyword.tact | 2 + ...uncid-native-fun-number-hexadecimal-2.tact | 2 + .../funcid-native-fun-number-neg-decimal.tact | 2 + ...cid-native-fun-number-neg-hexadecimal.tact | 2 + .../funcid-native-fun-square-brackets.tact | 2 + .../funcid-native-fun-type-keyword.tact | 2 + src/grammar/test/items-native-fun-funcid.tact | 75 ++ 17 files changed, 758 insertions(+), 16 deletions(-) create mode 100644 src/grammar/test-failed/funcid-native-fun-arith-operator.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-assign-operator.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-bitwise-operator.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-comparison-operator.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-control-keyword.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-delimiter.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-directive.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-keyword.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-number-hexadecimal-2.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-number-neg-decimal.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-number-neg-hexadecimal.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-square-brackets.tact create mode 100644 src/grammar/test-failed/funcid-native-fun-type-keyword.tact diff --git a/CHANGELOG.md b/CHANGELOG.md index fefeeb5c4..a627b248d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- FunC function identifiers with characters from hexadecimal set: PR [#636](https://github.com/tact-lang/tact/pull/636) + ## [1.4.1] - 2024-07-26 ### Added diff --git a/src/grammar/__snapshots__/grammar.spec.ts.snap b/src/grammar/__snapshots__/grammar.spec.ts.snap index 2677286fe..054c91939 100644 --- a/src/grammar/__snapshots__/grammar.spec.ts.snap +++ b/src/grammar/__snapshots__/grammar.spec.ts.snap @@ -71,6 +71,36 @@ Line 2, col 24: " `; +exports[`grammar should fail funcid-native-fun-arith-operator 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(/) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-assign-operator 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(^>>=) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-bitwise-operator 1`] = ` +":1:8: Parse error: expected not (a whiteSpace or "(" or ")" or "[" or "]" or "," or "." or ";" or "~") or "\`" + +Line 1, col 8: +> 1 | @name(~) + ^ + 2 | native idTest(); +" +`; + exports[`grammar should fail funcid-native-fun-comma 1`] = ` ":1:19: Parse error: expected ")" @@ -81,6 +111,46 @@ Line 1, col 19: " `; +exports[`grammar should fail funcid-native-fun-comparison-operator 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(<=>) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-control-keyword 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(elseifnot) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-delimiter 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name([) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-directive 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(#include) + ^ + 2 | native idTest(); +" +`; + exports[`grammar should fail funcid-native-fun-dot 1`] = ` ":1:10: Parse error: expected ")" @@ -91,6 +161,16 @@ Line 1, col 10: " `; +exports[`grammar should fail funcid-native-fun-keyword 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(global) + ^ + 2 | native idTest(); +" +`; + exports[`grammar should fail funcid-native-fun-multiline-comments 1`] = ` ":1:7: Parse error: expected not ("\\"" or "{-") @@ -102,41 +182,71 @@ Line 1, col 7: `; exports[`grammar should fail funcid-native-fun-number 1`] = ` -":1:10: Parse error: expected not (a whiteSpace or "(" or ")" or "," or "." or ";" or "~") +":1:7: Parse error: expected not a funcInvalidId or "\`" -Line 1, col 10: +Line 1, col 7: > 1 | @name(123) - ^ + ^ 2 | native idTest(); " `; exports[`grammar should fail funcid-native-fun-number-decimal 1`] = ` -":1:8: Parse error: expected not (a whiteSpace or "(" or ")" or "," or "." or ";" or "~") +":1:7: Parse error: expected not a funcInvalidId or "\`" -Line 1, col 8: +Line 1, col 7: > 1 | @name(0) - ^ + ^ 2 | native idTest(); " `; exports[`grammar should fail funcid-native-fun-number-hexadecimal 1`] = ` -":1:10: Parse error: expected not (a whiteSpace or "(" or ")" or "," or "." or ";" or "~") +":1:7: Parse error: expected not a funcInvalidId or "\`" -Line 1, col 10: +Line 1, col 7: > 1 | @name(0x0) - ^ + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-number-hexadecimal-2 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(0xDEADBEEF) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-number-neg-decimal 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(-1) + ^ + 2 | native idTest(); +" +`; + +exports[`grammar should fail funcid-native-fun-number-neg-hexadecimal 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(-0x0) + ^ 2 | native idTest(); " `; exports[`grammar should fail funcid-native-fun-only-underscore 1`] = ` -":1:8: Parse error: expected not (a whiteSpace or "(" or ")" or "," or "." or ";" or "~") +":1:7: Parse error: expected not a funcInvalidId or "\`" -Line 1, col 8: +Line 1, col 7: > 1 | @name(_) - ^ + ^ 2 | native idTest(); " `; @@ -171,6 +281,16 @@ Line 1, col 11: " `; +exports[`grammar should fail funcid-native-fun-square-brackets 1`] = ` +":1:11: Parse error: expected ")" + +Line 1, col 11: +> 1 | @name(take[some]entry) + ^ + 2 | native idTest(); +" +`; + exports[`grammar should fail funcid-native-fun-string 1`] = ` ":1:7: Parse error: expected not ("\\"" or "{-") @@ -181,8 +301,18 @@ Line 1, col 7: " `; +exports[`grammar should fail funcid-native-fun-type-keyword 1`] = ` +":1:7: Parse error: expected not a funcInvalidId or "\`" + +Line 1, col 7: +> 1 | @name(->) + ^ + 2 | native idTest(); +" +`; + exports[`grammar should fail funcid-native-fun-unclosed-parens 1`] = ` -":1:9: Parse error: expected not (a whiteSpace or "(" or ")" or "," or "." or ";" or "~") +":1:9: Parse error: expected ")" Line 1, col 9: > 1 | @name(aa(bb) @@ -3821,7 +3951,7 @@ native testFunc(): Bool;, exports[`grammar should parse items-native-fun-funcid 1`] = ` { - "id": 55, + "id": 124, "imports": [], "items": [ { @@ -4202,6 +4332,489 @@ native idTest18();, "params": [], "return": null, }, + { + "attributes": [], + "id": 57, + "kind": "native_function_decl", + "loc": @name(C4) +native idTest19();, + "name": { + "id": 55, + "kind": "id", + "loc": idTest19, + "text": "idTest19", + }, + "nativeName": { + "id": 56, + "kind": "func_id", + "loc": C4, + "text": "C4", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 60, + "kind": "native_function_decl", + "loc": @name(C4g) +native idTest20();, + "name": { + "id": 58, + "kind": "id", + "loc": idTest20, + "text": "idTest20", + }, + "nativeName": { + "id": 59, + "kind": "func_id", + "loc": C4g, + "text": "C4g", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 63, + "kind": "native_function_decl", + "loc": @name(4C) +native idTest21();, + "name": { + "id": 61, + "kind": "id", + "loc": idTest21, + "text": "idTest21", + }, + "nativeName": { + "id": 62, + "kind": "func_id", + "loc": 4C, + "text": "4C", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 66, + "kind": "native_function_decl", + "loc": @name(_0x0) +native idTest22();, + "name": { + "id": 64, + "kind": "id", + "loc": idTest22, + "text": "idTest22", + }, + "nativeName": { + "id": 65, + "kind": "func_id", + "loc": _0x0, + "text": "_0x0", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 69, + "kind": "native_function_decl", + "loc": @name(_0) +native idTest23();, + "name": { + "id": 67, + "kind": "id", + "loc": idTest23, + "text": "idTest23", + }, + "nativeName": { + "id": 68, + "kind": "func_id", + "loc": _0, + "text": "_0", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 72, + "kind": "native_function_decl", + "loc": @name(0x_) +native idTest24();, + "name": { + "id": 70, + "kind": "id", + "loc": idTest24, + "text": "idTest24", + }, + "nativeName": { + "id": 71, + "kind": "func_id", + "loc": 0x_, + "text": "0x_", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 75, + "kind": "native_function_decl", + "loc": @name(0x0_) +native idTest25();, + "name": { + "id": 73, + "kind": "id", + "loc": idTest25, + "text": "idTest25", + }, + "nativeName": { + "id": 74, + "kind": "func_id", + "loc": 0x0_, + "text": "0x0_", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 78, + "kind": "native_function_decl", + "loc": @name(0_) +native idTest26();, + "name": { + "id": 76, + "kind": "id", + "loc": idTest26, + "text": "idTest26", + }, + "nativeName": { + "id": 77, + "kind": "func_id", + "loc": 0_, + "text": "0_", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 81, + "kind": "native_function_decl", + "loc": @name(hash#256) +native idTest27();, + "name": { + "id": 79, + "kind": "id", + "loc": idTest27, + "text": "idTest27", + }, + "nativeName": { + "id": 80, + "kind": "func_id", + "loc": hash#256, + "text": "hash#256", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 84, + "kind": "native_function_decl", + "loc": @name(💀💀💀0xDEADBEEF💀💀💀) +native idTest28();, + "name": { + "id": 82, + "kind": "id", + "loc": idTest28, + "text": "idTest28", + }, + "nativeName": { + "id": 83, + "kind": "func_id", + "loc": 💀💀💀0xDEADBEEF💀💀💀, + "text": "💀💀💀0xDEADBEEF💀💀💀", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 87, + "kind": "native_function_decl", + "loc": @name(__tact_verify_address) +native idTest29();, + "name": { + "id": 85, + "kind": "id", + "loc": idTest29, + "text": "idTest29", + }, + "nativeName": { + "id": 86, + "kind": "func_id", + "loc": __tact_verify_address, + "text": "__tact_verify_address", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 90, + "kind": "native_function_decl", + "loc": @name(__tact_pow2) +native idTest30();, + "name": { + "id": 88, + "kind": "id", + "loc": idTest30, + "text": "idTest30", + }, + "nativeName": { + "id": 89, + "kind": "func_id", + "loc": __tact_pow2, + "text": "__tact_pow2", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 93, + "kind": "native_function_decl", + "loc": @name(randomize_lt) +native idTest31();, + "name": { + "id": 91, + "kind": "id", + "loc": idTest31, + "text": "idTest31", + }, + "nativeName": { + "id": 92, + "kind": "func_id", + "loc": randomize_lt, + "text": "randomize_lt", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 96, + "kind": "native_function_decl", + "loc": @name(fixed248::asin) +native idTest32();, + "name": { + "id": 94, + "kind": "id", + "loc": idTest32, + "text": "idTest32", + }, + "nativeName": { + "id": 95, + "kind": "func_id", + "loc": fixed248::asin, + "text": "fixed248::asin", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 99, + "kind": "native_function_decl", + "loc": @name(fixed248::nrand_fast) +native idTest33();, + "name": { + "id": 97, + "kind": "id", + "loc": idTest33, + "text": "idTest33", + }, + "nativeName": { + "id": 98, + "kind": "func_id", + "loc": fixed248::nrand_fast, + "text": "fixed248::nrand_fast", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 102, + "kind": "native_function_decl", + "loc": @name(atan_f261_inlined) +native idTest34();, + "name": { + "id": 100, + "kind": "id", + "loc": idTest34, + "text": "idTest34", + }, + "nativeName": { + "id": 101, + "kind": "func_id", + "loc": atan_f261_inlined, + "text": "atan_f261_inlined", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 105, + "kind": "native_function_decl", + "loc": @name(~impure_touch) +native idTest35();, + "name": { + "id": 103, + "kind": "id", + "loc": idTest35, + "text": "idTest35", + }, + "nativeName": { + "id": 104, + "kind": "func_id", + "loc": ~impure_touch, + "text": "~impure_touch", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 108, + "kind": "native_function_decl", + "loc": @name(~udict::delete_get_min) +native idTest36();, + "name": { + "id": 106, + "kind": "id", + "loc": idTest36, + "text": "idTest36", + }, + "nativeName": { + "id": 107, + "kind": "func_id", + "loc": ~udict::delete_get_min, + "text": "~udict::delete_get_min", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 111, + "kind": "native_function_decl", + "loc": @name(.something) +native idTest37();, + "name": { + "id": 109, + "kind": "id", + "loc": idTest37, + "text": "idTest37", + }, + "nativeName": { + "id": 110, + "kind": "func_id", + "loc": .something, + "text": ".something", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 114, + "kind": "native_function_decl", + "loc": @name(f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕) +native idTest38();, + "name": { + "id": 112, + "kind": "id", + "loc": idTest38, + "text": "idTest38", + }, + "nativeName": { + "id": 113, + "kind": "func_id", + "loc": f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕, + "text": "f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 117, + "kind": "native_function_decl", + "loc": @name(❤️❤️❤️thanks❤️❤️❤️) +native idTest39();, + "name": { + "id": 115, + "kind": "id", + "loc": idTest39, + "text": "idTest39", + }, + "nativeName": { + "id": 116, + "kind": "func_id", + "loc": ❤️❤️❤️thanks❤️❤️❤️, + "text": "❤️❤️❤️thanks❤️❤️❤️", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 120, + "kind": "native_function_decl", + "loc": @name(intslice) +native idTest40();, + "name": { + "id": 118, + "kind": "id", + "loc": idTest40, + "text": "idTest40", + }, + "nativeName": { + "id": 119, + "kind": "func_id", + "loc": intslice, + "text": "intslice", + }, + "params": [], + "return": null, + }, + { + "attributes": [], + "id": 123, + "kind": "native_function_decl", + "loc": @name(int2) +native idTest40();, + "name": { + "id": 121, + "kind": "id", + "loc": idTest40, + "text": "idTest40", + }, + "nativeName": { + "id": 122, + "kind": "func_id", + "loc": int2, + "text": "int2", + }, + "params": [], + "return": null, + }, ], "kind": "module", } diff --git a/src/grammar/grammar.ohm b/src/grammar/grammar.ohm index a253dadc7..17ebb582f 100644 --- a/src/grammar/grammar.ohm +++ b/src/grammar/grammar.ohm @@ -263,13 +263,39 @@ Tact { id = ~reservedWord #idStart #(idPart*) // FunC identifiers, where `funcId` stands for FunC function identifier - // The plain identifier cannot be a single underscore nor just a number - funcPlainId = "_"? "-"? "0x"? hexDigit* ~hexDigit (~(whiteSpace | "(" | ")" | "," | "." | ";" | "~") any)+ + // A plain identifier cannot be a number, a single underscore, an operator, a keyword or a compiler directive + // See: https://github.com/ton-blockchain/ton/blob/master/crypto/func/keywords.cpp + + // Order of inner alternations matters + funcInvalidId = "_" ")" --notUnderscore + | ("+" | "-" | "*" | "/%" | "/" | "%" | "~/" | "^/" | "~%" | "^%") ")" --notArithOperator + | ("<=>" | "<=" | "<" | ">=" | ">" | "!=" | "==") ")" --notComparisonOperator + | ("~>>" | "~" | "^>>" | "^" | "&" | "|" | "<<" | ">>" ) ")" --notBitwiseOperator + | ("=" | "+=" | "-=" | "*=" | "/=" | "%=" + | "~>>=" | "~/=" | "~%=" | "^>>=" | "^/=" | "^%=" | "^=" + | "<<=" | ">>=" | "&=" | "|=") ")" --notAssignOperator + | ("[" | "]" | "{" | "}" | "?" | ":") ")" --notDelimiter + | ("return" | "var" | "repeat" | "do" | "while" | "until" | "try" | "catch" + | "ifnot" | "if" | "then" | "elseifnot" | "elseif" | "else") ")" --notControlKeyword + | ("int" | "cell" | "builder" | "slice" | "cont" | "tuple" | "type" | "->" | "forall") ")" --notTypeKeyword + | ("extern" | "global" | "asm" | "impure" | "inline_ref" | "inline" | "auto_apply" | "method_id" + | "operator" | "infixl" | "infixr" | "infix" | "const") ")" --notKeyword + | ("#include" | "#pragma") ")" --notDirective + | ("-"? digit+) ")" --notDecimalNumber + | ("-"? "0x" hexDigit+) ")" --notHexadecimalNumber + + funcPlainId = ~funcInvalidId (~(whiteSpace | "(" | ")" | "[" | "]" | "," | "." | ";" | "~") any)+ funcQuotedId = "`" (~("`" | "\n") any)+ "`" funcId = ~("\"" | "{-") ("." | "~")? (funcQuotedId | funcPlainId) + /* + FunC can parse much more than Fift can handle. For example, _0x0 and _0 are valid identifiers in FunC, and using either of them compiles and is then interpreted fine by Fift. But if you use both, FunC still compiles, but Fift crashes. + + Same goes for plain identifiers using hashes # or emojis — you can have one FunC function with any of those combinations of characters, but you (generally) cannot have two or more of such functions. + */ + // Boolean literals boolLiteral = ("true" | "false") ~idPart diff --git a/src/grammar/test-failed/funcid-native-fun-arith-operator.tact b/src/grammar/test-failed/funcid-native-fun-arith-operator.tact new file mode 100644 index 000000000..e62909e01 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-arith-operator.tact @@ -0,0 +1,2 @@ +@name(/) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-assign-operator.tact b/src/grammar/test-failed/funcid-native-fun-assign-operator.tact new file mode 100644 index 000000000..7f942d2fd --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-assign-operator.tact @@ -0,0 +1,2 @@ +@name(^>>=) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-bitwise-operator.tact b/src/grammar/test-failed/funcid-native-fun-bitwise-operator.tact new file mode 100644 index 000000000..e9b553502 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-bitwise-operator.tact @@ -0,0 +1,2 @@ +@name(~) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-comparison-operator.tact b/src/grammar/test-failed/funcid-native-fun-comparison-operator.tact new file mode 100644 index 000000000..76b241bcd --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-comparison-operator.tact @@ -0,0 +1,2 @@ +@name(<=>) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-control-keyword.tact b/src/grammar/test-failed/funcid-native-fun-control-keyword.tact new file mode 100644 index 000000000..4c9bb9dde --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-control-keyword.tact @@ -0,0 +1,2 @@ +@name(elseifnot) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-delimiter.tact b/src/grammar/test-failed/funcid-native-fun-delimiter.tact new file mode 100644 index 000000000..0d6689502 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-delimiter.tact @@ -0,0 +1,2 @@ +@name([) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-directive.tact b/src/grammar/test-failed/funcid-native-fun-directive.tact new file mode 100644 index 000000000..6ded6ea60 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-directive.tact @@ -0,0 +1,2 @@ +@name(#include) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-keyword.tact b/src/grammar/test-failed/funcid-native-fun-keyword.tact new file mode 100644 index 000000000..9d4497a45 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-keyword.tact @@ -0,0 +1,2 @@ +@name(global) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-number-hexadecimal-2.tact b/src/grammar/test-failed/funcid-native-fun-number-hexadecimal-2.tact new file mode 100644 index 000000000..ef3db123b --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-number-hexadecimal-2.tact @@ -0,0 +1,2 @@ +@name(0xDEADBEEF) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-number-neg-decimal.tact b/src/grammar/test-failed/funcid-native-fun-number-neg-decimal.tact new file mode 100644 index 000000000..05b304f67 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-number-neg-decimal.tact @@ -0,0 +1,2 @@ +@name(-1) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-number-neg-hexadecimal.tact b/src/grammar/test-failed/funcid-native-fun-number-neg-hexadecimal.tact new file mode 100644 index 000000000..98f707094 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-number-neg-hexadecimal.tact @@ -0,0 +1,2 @@ +@name(-0x0) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-square-brackets.tact b/src/grammar/test-failed/funcid-native-fun-square-brackets.tact new file mode 100644 index 000000000..e93bbb9d9 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-square-brackets.tact @@ -0,0 +1,2 @@ +@name(take[some]entry) +native idTest(); diff --git a/src/grammar/test-failed/funcid-native-fun-type-keyword.tact b/src/grammar/test-failed/funcid-native-fun-type-keyword.tact new file mode 100644 index 000000000..f0abd9e96 --- /dev/null +++ b/src/grammar/test-failed/funcid-native-fun-type-keyword.tact @@ -0,0 +1,2 @@ +@name(->) +native idTest(); diff --git a/src/grammar/test/items-native-fun-funcid.tact b/src/grammar/test/items-native-fun-funcid.tact index d4fa3b818..90ca19a94 100644 --- a/src/grammar/test/items-native-fun-funcid.tact +++ b/src/grammar/test/items-native-fun-funcid.tact @@ -51,3 +51,78 @@ native idTest17(); @name(`any symbols ; ~ () are allowed here...`) native idTest18(); + +@name(C4) +native idTest19(); + +@name(C4g) +native idTest20(); + +@name(4C) +native idTest21(); + +// Fun fact: +// Individually, _0x0 and _0 are totally valid identifiers in FunC, and the resulting Fift works fine too. +// But if they're together, FunC still compiles, but Fift interpreter cannot deal with that and crashes. +// Same goes for identifiers using hashes # or emojis. +// I.e., you can have a function with any of those combinations of characters, but only one. + +@name(_0x0) +native idTest22(); + +@name(_0) +native idTest23(); + +@name(0x_) +native idTest24(); + +@name(0x0_) +native idTest25(); + +@name(0_) +native idTest26(); + +@name(hash#256) +native idTest27(); + +@name(💀💀💀0xDEADBEEF💀💀💀) +native idTest28(); + +@name(__tact_verify_address) +native idTest29(); + +@name(__tact_pow2) +native idTest30(); + +@name(randomize_lt) +native idTest31(); + +@name(fixed248::asin) +native idTest32(); + +@name(fixed248::nrand_fast) +native idTest33(); + +@name(atan_f261_inlined) +native idTest34(); + +@name(~impure_touch) +native idTest35(); + +@name(~udict::delete_get_min) +native idTest36(); + +@name(.something) +native idTest37(); + +@name(f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕) +native idTest38(); + +@name(❤️❤️❤️thanks❤️❤️❤️) +native idTest39(); + +@name(intslice) +native idTest40(); + +@name(int2) +native idTest40();