diff --git a/regression-tests/mixed-inspect-templates.cpp2 b/regression-tests/mixed-inspect-templates.cpp2 index 411eb30dd1..18e8d69a8f 100644 --- a/regression-tests/mixed-inspect-templates.cpp2 +++ b/regression-tests/mixed-inspect-templates.cpp2 @@ -16,10 +16,10 @@ fun: (v : _) -> std::string = { } fun2: (v : _) -> std::string = { - if v is std::vector { return "std::vector"; } - if v is std::array { return "std::array"; } - if v is std::variant { return "std::variant"; } - if v is my_type { return "my_type"; } + if (v) is std::vector { return "std::vector"; } + if (v) is std::array { return "std::array"; } + if (v) is std::variant { return "std::variant"; } + if (v) is my_type { return "my_type"; } return "unknown"; } @@ -38,4 +38,4 @@ main: () -> int = { std::cout << "inspected arr : (fun2(arr))$" << std::endl; std::cout << "inspected var : (fun2(var))$" << std::endl; std::cout << "inspected myt : (fun2(myt))$" << std::endl; -} \ No newline at end of file +} diff --git a/regression-tests/mixed-inspect-values-2.cpp2 b/regression-tests/mixed-inspect-values-2.cpp2 index ed250e52b0..75766a4a0d 100644 --- a/regression-tests/mixed-inspect-values-2.cpp2 +++ b/regression-tests/mixed-inspect-values-2.cpp2 @@ -25,11 +25,11 @@ main: () -> int = { is _ = "i is out of our interest"; } << std::endl; - if i is (less_than(20)) { + if (i) is (less_than(20)) { std::cout << "less than 20" << std::endl; } - if i is (in(10,30)) { + if (i) is (in(10,30)) { std::cout << "i is between 10 and 30" << std::endl; } @@ -39,7 +39,7 @@ main: () -> int = { std::cout << "v is empty" << std::endl; } - if v is (empty) { + if (v) is (empty) { std::cout << "v is empty" << std::endl; } } diff --git a/regression-tests/pure2-enum.cpp2 b/regression-tests/pure2-enum.cpp2 index 4f1f886f21..6a5389329b 100644 --- a/regression-tests/pure2-enum.cpp2 +++ b/regression-tests/pure2-enum.cpp2 @@ -49,7 +49,7 @@ main: () = { else if skat_game::hearts == x { // ok, in either order std::cout << "hearts"; } - else if x is (skat_game::spades) { // ok, using is + else if (x) is (skat_game::spades) { // ok, using is std::cout << "spades"; } else if skat_game::clubs is (x) { // ok, using is @@ -95,8 +95,8 @@ main: () = { std::cout << "f. get_raw_value() is (f. get_raw_value())$\n"; std::cout << "f2.get_raw_value() is (f2.get_raw_value())$\n"; - std::cout << "f is (f2) is (f is (f2))$\n"; - std::cout << "f2 is (f ) is (f2 is (f ))$\n\n"; + std::cout << "(f ) is (f2) is ((f ) is (f2))$\n"; + std::cout << "(f2) is (f ) is ((f2) is (f ))$\n\n"; f.clear( f2 ); f.set( file_attributes::current | f2 ); @@ -108,8 +108,8 @@ main: () = { std::cout << "f. get_raw_value() is (f. get_raw_value())$\n"; std::cout << "f2.get_raw_value() is (f2.get_raw_value())$\n"; std::cout << "f == f2 is (f == f2 )$\n"; - std::cout << "f is (f2) is (f is (f2))$\n"; - std::cout << "f2 is (f ) is (f2 is (f ))$\n"; + std::cout << "(f ) is (f2) is ((f ) is (f2))$\n"; + std::cout << "(f2) is (f ) is ((f2) is (f ))$\n"; std::cout << "(f & f2) == f2 is ((f & f2) == f2)$\n"; std::cout << "inspecting f: " << inspect f -> std::string { diff --git a/regression-tests/pure2-more-wildcards.cpp2 b/regression-tests/pure2-more-wildcards.cpp2 index 2dc8b0f499..6f06c65f4d 100644 --- a/regression-tests/pure2-more-wildcards.cpp2 +++ b/regression-tests/pure2-more-wildcards.cpp2 @@ -7,11 +7,11 @@ main: () -> int p: * _ = x&; q: * const _ = p&; - if x is (less_than(20)) { + if (x) is (less_than(20)) { std::cout << "yes, less\n"; } - if x is _ { + if (x) is _ { std::cout << "yes, always\n"; } } diff --git a/regression-tests/pure2-type-safety-1.cpp2 b/regression-tests/pure2-type-safety-1.cpp2 index 049c9075d5..69a55efd5f 100644 --- a/regression-tests/pure2-type-safety-1.cpp2 +++ b/regression-tests/pure2-type-safety-1.cpp2 @@ -23,7 +23,7 @@ main: () -> int = test_generic: ( x, msg ) = { msgx: std::string = msg; - print( msgx + " is int? ", x is int ); + print( msgx + " is int? ", (x) is int ); } print: ( msg: std::string, b: bool ) = { diff --git a/source/parse.h b/source/parse.h index 213fd20ca4..249fea82ee 100644 --- a/source/parse.h +++ b/source/parse.h @@ -6015,10 +6015,10 @@ class parser //G is-as-expression: //G prefix-expression + //GTODO type-id is-type-constraint //G is-as-expression is-type-constraint //G is-as-expression is-value-constraint //G is-as-expression as-type-cast - //GTODO type-id is-type-constraint //G //G is-type-constraint //G 'is' type-id @@ -6033,6 +6033,17 @@ class parser -> std::unique_ptr { auto n = std::make_unique(); + + if ( + curr().type() == lexeme::Identifier + && peek(1) + && *peek(1) == "is" + ) + { + error("(temporary alpha limitation) testing a type with 'is' is not supported yet (or perhaps use '(identifier) is' to test an expression)"); + return {}; + } + n->expr = prefix_expression(); if (!(n->expr)) { return {};