
* Allow compile-time constants as toplevel declarations * Remove the test that fails on toplevel consts * Warn when shadowing a constant * Allow records to be used as compile time constants * Allow data constructors in compile-time constants * Disable some warnings for toplevel constants Since variables and functions cannot be used in the definition of a compile time constants, the following warnings are not going to be reported: * Used/Unused variable * Used/Unused function * Do not reverse constants declarations * Add tests for all valid expressions * Add test for accessing const from namespace * Revert "Do not reverse constants declarations" This reverts commit c4647fadacd134866e4be9c2ab4b0d54870a35fd. * Add test for assigining constant to a constant * Show empty map or record error when assigning to const * Report all invalid constant expressions before fail * Allow accessing records fields in toplevel consts * Undo a mistake * Add test for warning on const shadowing * Show error message when using pattern matching for consts * Remove unused error * Ban toplevel constants in contract interfaces * Varibles rename * Change the error message for invalid_const_id * Make constants public in namespaces and private in contracts * Add a warning about unused constants in contracts * Use ban_when_const for function applications * Test for qualified access of constants in functions * Add failing tests * Add test for the unused const warning * Update CHANGELOG * Update all_syntax test file * Treat expr and type inside bound as bound * Allow typed ids to be used for constants * List valid exprs in the error message for invalid exprs * Fix tests * Update the docs about constants * Update syntax docs * Check validity of const exprs in a separate functions * Call both resolve_const and resolve_fun from resolve_var
87 lines
2.2 KiB
Plaintext
87 lines
2.2 KiB
Plaintext
// Try to cover all syntactic constructs.
|
|
@compiler > 0
|
|
@compiler =< 10.1.1.1.1.1.2.3.4
|
|
|
|
|
|
namespace Ns =
|
|
datatype d('a) = D | S(int) | M('a, list('a), int)
|
|
private function fff() = 123
|
|
let const = 1
|
|
|
|
stateful entrypoint
|
|
f (1, x) = (_) => x
|
|
|
|
payable contract AllSyntaxType =
|
|
/** Multi-
|
|
* line
|
|
* comment
|
|
*/
|
|
stateful function foo : _
|
|
entrypoint bar : int => (int * 'a)
|
|
|
|
|
|
contract AllSyntax =
|
|
|
|
datatype mickiewicz = Adam | Mickiewicz
|
|
record goethe('a, 'b) = {
|
|
johann : int,
|
|
wolfgang : 'a,
|
|
von : 'a * 'b * int,
|
|
goethe : unit
|
|
}
|
|
type dante = Ns.d(int)
|
|
type shakespeare('a) = goethe('a, 'a)
|
|
|
|
type state = shakespeare(int)
|
|
|
|
let cc = "str"
|
|
|
|
entrypoint init() = {
|
|
johann = 1000,
|
|
wolfgang = -10,
|
|
|
|
/* TODO: This does not compile because of bug in the parser tester.
|
|
von = (2 + 2, 0, List.sum([x | k <- [1,2,3]
|
|
, let l = k + 1
|
|
, if(l < 10)
|
|
, let f(x) = x + 100
|
|
, Adam <- [Adam, Mickiewicz]
|
|
, let x = f(l)
|
|
])),
|
|
*/
|
|
von = (2 + 2, 0, List.sum([1,2,3,4])),
|
|
goethe = () }
|
|
|
|
function f() =
|
|
let kp = "nietzsche"
|
|
// let p = "Пушкин" // TODO: this also doesn't do right round_trip...
|
|
let k(x : bytes(8)) : bytes(8) = Bytes.to_int(#fedcba9876543210)
|
|
|
|
let f : () => address = () => ak_2gx9MEFxKvY9vMG5YnqnXWv1hCsX7rgnfvBLJS4aQurustR1rt
|
|
if(Bits.test(Bits.all, 10))
|
|
abort("ohno")
|
|
if(true && false)
|
|
require(true, "ohyes")
|
|
elif(false || 2 == 2)
|
|
()
|
|
else
|
|
()
|
|
if(true) f(1,2)((1,2))
|
|
else switch(1::[1,2,3])
|
|
[] => 1
|
|
a::b => 123
|
|
1::2::3 => 123123
|
|
[2,3,4] => 1
|
|
_ => 13
|
|
1::[2] => 2138
|
|
put(state{johann = 1})
|
|
|
|
let m = {["foo"] = 19, /*hey wanna talk about inlined comments?*/ ["bar"] = 42}
|
|
let n = {}
|
|
m{ ["x" = 0] @ z = z + state.johann }
|
|
|
|
let sh : shakespeare(shakespeare(int)) =
|
|
{wolfgang = state}
|
|
sh{wolfgang.wolfgang = sh.wolfgang} // comment
|
|
exit("hope you had fun reading this")
|