diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f9a4e9..b2d5a269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [4.3.1] 2024-08-24 + +### Added + - Added support for "is not" type test + ## [4.3.0] 2024-08-18 ### Added diff --git a/gdtoolkit/parser/gdscript.lark b/gdtoolkit/parser/gdscript.lark index 401fb571..b06bc3d3 100644 --- a/gdtoolkit/parser/gdscript.lark +++ b/gdtoolkit/parser/gdscript.lark @@ -223,9 +223,9 @@ not_in_op: "not" "in" !?pow_expr: type_test ("**" asless_type_test)* | actual_type_cast ("**" asless_type_test)+ !?asless_pow_expr: asless_type_test ("**" asless_type_test)* -!?type_test: await_expr ("is" TYPE_HINT)* - | actual_type_cast ("is" TYPE_HINT)+ -!?asless_type_test: await_expr ("is" TYPE_HINT)* +!?type_test: await_expr (("is" | "is not") TYPE_HINT)* + | actual_type_cast (("is" | "is not") TYPE_HINT)+ +!?asless_type_test: await_expr (("is" | "is not") TYPE_HINT)* !?await_expr: ("await")* call_expr ?call_expr: attr_expr | (NAME | GET | SET) _call_arglist -> standalone_call diff --git a/tests/formatter/input-output-pairs/type_test_expressions.in.gd b/tests/formatter/input-output-pairs/type_test_expressions.in.gd index 647f167c..0de02ddd 100644 --- a/tests/formatter/input-output-pairs/type_test_expressions.in.gd +++ b/tests/formatter/input-output-pairs/type_test_expressions.in.gd @@ -3,3 +3,5 @@ class X: var x = 1 is int is bool var y = 1 is int is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool print([1,2.1] is Array[int]) + var z = 1 is not int + var z1 = 1 is not int is not bool is not bool is not bool is not bool is not bool is not bool is not bool is not bool is not bool diff --git a/tests/formatter/input-output-pairs/type_test_expressions.out.gd b/tests/formatter/input-output-pairs/type_test_expressions.out.gd index 42ebc54b..5f0056f5 100644 --- a/tests/formatter/input-output-pairs/type_test_expressions.out.gd +++ b/tests/formatter/input-output-pairs/type_test_expressions.out.gd @@ -19,3 +19,17 @@ class X: is bool ) print([1, 2.1] is Array[int]) + var z = 1 is not int + var z1 = ( + 1 + is not int + is not bool + is not bool + is not bool + is not bool + is not bool + is not bool + is not bool + is not bool + is not bool + ) diff --git a/tests/valid-gd-scripts/expressions.gd b/tests/valid-gd-scripts/expressions.gd index 530117eb..b2e47d11 100644 --- a/tests/valid-gd-scripts/expressions.gd +++ b/tests/valid-gd-scripts/expressions.gd @@ -44,6 +44,7 @@ func foo(): ~8 5 ** 5 x is int + x is not int x is Xyz # TODO: fix/remove x.Type x is Zyx.Qwe # TODO: fix/remove x.Type x.attr