diff --git a/test/libsolidity/syntaxTests/experimental/algebraicTypes.sol b/test/libsolidity/syntaxTests/experimental/algebraicTypes.sol new file mode 100644 index 000000000..6c6e8d752 --- /dev/null +++ b/test/libsolidity/syntaxTests/experimental/algebraicTypes.sol @@ -0,0 +1,49 @@ +pragma experimental solidity; + +type word = __builtin("word"); +type bool = __builtin("bool"); +type unit = __builtin("unit"); + +type wordOrBool = word | bool; +type wordAndBool = (word, bool); + +function g() -> () {} + +function f() -> () { + let ptr1: unit -> unit = g; + let ptr2: () -> () = g; + + // FIXME: Does not unify: + //let ptr3: () -> () | () -> () = g; + //let ptr4: unit -> unit | () -> () = g; + //let ptr5: word | () -> () = g; +} +// ---- +// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (31-61): Inferred type: word +// Info 4164: (62-92): Inferred type: bool +// Info 4164: (93-123): Inferred type: () +// Info 4164: (125-155): Inferred type: wordOrBool +// Info 4164: (143-154): Inferred type: sum(word, bool) +// Info 4164: (143-147): Inferred type: word +// Info 4164: (150-154): Inferred type: bool +// Info 4164: (156-188): Inferred type: wordAndBool +// Info 4164: (175-187): Inferred type: (word, bool) +// Info 4164: (176-180): Inferred type: word +// Info 4164: (182-186): Inferred type: bool +// Info 4164: (190-211): Inferred type: () -> () +// Info 4164: (200-202): Inferred type: () +// Info 4164: (206-208): Inferred type: () +// Info 4164: (213-449): Inferred type: () -> () +// Info 4164: (223-225): Inferred type: () +// Info 4164: (229-231): Inferred type: () +// Info 4164: (242-260): Inferred type: () -> () +// Info 4164: (248-260): Inferred type: () -> () +// Info 4164: (248-252): Inferred type: () +// Info 4164: (256-260): Inferred type: () +// Info 4164: (263-264): Inferred type: () -> () +// Info 4164: (274-288): Inferred type: () -> () +// Info 4164: (280-288): Inferred type: () -> () +// Info 4164: (280-282): Inferred type: () +// Info 4164: (286-288): Inferred type: () +// Info 4164: (291-292): Inferred type: () -> () diff --git a/test/libsolidity/syntaxTests/experimental/inference/class_and_instantiation_order.sol b/test/libsolidity/syntaxTests/experimental/inference/class_and_instantiation_order.sol new file mode 100644 index 000000000..5a9c4740a --- /dev/null +++ b/test/libsolidity/syntaxTests/experimental/inference/class_and_instantiation_order.sol @@ -0,0 +1,52 @@ +pragma experimental solidity; + +type word = __builtin("word"); + +type T = word; + +class Self: C { + function f(self: Self) -> word; +} + +instantiation T: C { + function f(self: T) -> word {} +} + +instantiation T: D { + function f(self: T) -> word {} +} + +class Self: D { + function f(self: Self) -> word; +} +// ---- +// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (31-61): Inferred type: word +// Info 4164: (63-77): Inferred type: T:(type, C, D) +// Info 4164: (72-76): Inferred type: word +// Info 4164: (79-132): Inferred type: C +// Info 4164: (85-89): Inferred type: 'bb:(type, C) +// Info 4164: (99-130): Inferred type: 'bb:(type, C) -> word +// Info 4164: (109-121): Inferred type: 'bb:(type, C) +// Info 4164: (110-120): Inferred type: 'bb:(type, C) +// Info 4164: (116-120): Inferred type: 'bb:(type, C) +// Info 4164: (125-129): Inferred type: word +// Info 4164: (134-191): Inferred type: void +// Info 4164: (159-189): Inferred type: T -> word +// Info 4164: (169-178): Inferred type: T +// Info 4164: (170-177): Inferred type: T +// Info 4164: (176-177): Inferred type: T +// Info 4164: (182-186): Inferred type: word +// Info 4164: (193-250): Inferred type: void +// Info 4164: (218-248): Inferred type: T -> word +// Info 4164: (228-237): Inferred type: T +// Info 4164: (229-236): Inferred type: T +// Info 4164: (235-236): Inferred type: T +// Info 4164: (241-245): Inferred type: word +// Info 4164: (252-305): Inferred type: D +// Info 4164: (258-262): Inferred type: 'bi:(type, D) +// Info 4164: (272-303): Inferred type: 'bi:(type, D) -> word +// Info 4164: (282-294): Inferred type: 'bi:(type, D) +// Info 4164: (283-293): Inferred type: 'bi:(type, D) +// Info 4164: (289-293): Inferred type: 'bi:(type, D) +// Info 4164: (298-302): Inferred type: word diff --git a/test/libsolidity/syntaxTests/experimental/inference/infinite_recursion_two_functions.sol b/test/libsolidity/syntaxTests/experimental/inference/infinite_recursion_two_functions.sol new file mode 100644 index 000000000..efcac2707 --- /dev/null +++ b/test/libsolidity/syntaxTests/experimental/inference/infinite_recursion_two_functions.sol @@ -0,0 +1,30 @@ +pragma experimental solidity; + +type word = __builtin("word"); + +function f(x: word) -> word { + g(x); +} + +function g(x: word) -> word { + f(x); +} +// ---- +// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (31-61): Inferred type: word +// Info 4164: (63-104): Inferred type: word -> word +// Info 4164: (73-82): Inferred type: word +// Info 4164: (74-81): Inferred type: word +// Info 4164: (77-81): Inferred type: word +// Info 4164: (86-90): Inferred type: word +// Info 4164: (97-101): Inferred type: word +// Info 4164: (97-98): Inferred type: word -> word +// Info 4164: (99-100): Inferred type: word +// Info 4164: (106-147): Inferred type: word -> word +// Info 4164: (116-125): Inferred type: word +// Info 4164: (117-124): Inferred type: word +// Info 4164: (120-124): Inferred type: word +// Info 4164: (129-133): Inferred type: word +// Info 4164: (140-144): Inferred type: word +// Info 4164: (140-141): Inferred type: word -> word +// Info 4164: (142-143): Inferred type: word diff --git a/test/libsolidity/syntaxTests/experimental/sorts.sol b/test/libsolidity/syntaxTests/experimental/sorts.sol new file mode 100644 index 000000000..f3eccd525 --- /dev/null +++ b/test/libsolidity/syntaxTests/experimental/sorts.sol @@ -0,0 +1,38 @@ +pragma experimental solidity; + +type word = __builtin("word"); +type uint = word; + +class Self: Number {} + +instantiation uint: Number {} + +function f(a: T: Number) {} + +function test() { + let x: uint: Number; + f(x); +} +// ---- +// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (31-61): Inferred type: word +// Info 4164: (62-79): Inferred type: uint:(type, Number) +// Info 4164: (74-78): Inferred type: word +// Info 4164: (81-102): Inferred type: Number +// Info 4164: (87-91): Inferred type: 'v:(type, Number) +// Info 4164: (104-133): Inferred type: void +// Info 4164: (135-162): Inferred type: 'z:(type, Number) -> () +// Info 4164: (145-159): Inferred type: 'z:(type, Number) +// Info 4164: (146-158): Inferred type: 'z:(type, Number) +// Info 4164: (149-158): Inferred type: 'z:(type, Number) +// Info 4164: (149-150): Inferred type: 'z:(type, Number) +// Info 4164: (152-158): Inferred type: 'z:(type, Number):(type, Number) +// Info 4164: (164-218): Inferred type: () -> () +// Info 4164: (177-179): Inferred type: () +// Info 4164: (190-205): Inferred type: uint +// Info 4164: (193-205): Inferred type: uint +// Info 4164: (193-197): Inferred type: uint +// Info 4164: (199-205): Inferred type: uint:(type, Number) +// Info 4164: (211-215): Inferred type: () +// Info 4164: (211-212): Inferred type: uint -> () +// Info 4164: (213-214): Inferred type: uint