Introduce contract-level compile-time constants #923

Merged
ghallak merged 37 commits from ghallak/387 into master 2023-04-12 20:20:41 +09:00

37 Commits

Author SHA1 Message Date
Gaith Hallak
274bb4e197 Call both resolve_const and resolve_fun from resolve_var 2023-04-12 13:02:24 +03:00
Gaith Hallak
521b382dd7 Check validity of const exprs in a separate functions 2023-04-12 13:02:24 +03:00
Gaith Hallak
da6d4877d6 Update syntax docs 2023-04-12 13:02:24 +03:00
Gaith Hallak
442c3a5625 Update the docs about constants 2023-04-12 13:02:24 +03:00
Gaith Hallak
2bafa3771e Fix tests 2023-04-12 13:01:56 +03:00
Gaith Hallak
ad851854be List valid exprs in the error message for invalid exprs 2023-04-12 13:01:56 +03:00
Gaith Hallak
d34760b990 Allow typed ids to be used for constants 2023-04-12 13:01:56 +03:00
Gaith Hallak
51935f8388 Treat expr and type inside bound as bound 2023-04-12 13:01:56 +03:00
Gaith Hallak
6308f009ca Update all_syntax test file 2023-04-12 13:01:56 +03:00
Gaith Hallak
6a5eff6db3 Update CHANGELOG 2023-04-12 13:01:56 +03:00
Gaith Hallak
e756f935f2 Add test for the unused const warning 2023-04-12 13:00:42 +03:00
Gaith Hallak
be7133dec7 Add failing tests 2023-04-12 13:00:42 +03:00
Gaith Hallak
0e154f96fa Test for qualified access of constants in functions 2023-04-12 12:55:24 +03:00
Gaith Hallak
95d372c718 Use ban_when_const for function applications 2023-04-12 12:55:24 +03:00
Gaith Hallak
42c34ce3d8 Add a warning about unused constants in contracts 2023-04-12 12:55:24 +03:00
Gaith Hallak
ec119a90c5 Make constants public in namespaces and private in contracts 2023-04-12 12:55:24 +03:00
Gaith Hallak
9174b90986 Change the error message for invalid_const_id 2023-04-12 12:55:24 +03:00
Gaith Hallak
342126b60e Varibles rename 2023-04-12 12:55:24 +03:00
Gaith Hallak
b23d40e1e6 Ban toplevel constants in contract interfaces 2023-04-12 12:55:24 +03:00
Gaith Hallak
162ad4667e Remove unused error 2023-04-12 12:55:24 +03:00
Gaith Hallak
0c2421c528 Show error message when using pattern matching for consts 2023-04-12 12:55:24 +03:00
Gaith Hallak
28b26ea4cc Add test for warning on const shadowing 2023-04-12 12:55:24 +03:00
Gaith Hallak
de34fc1122 Undo a mistake 2023-04-12 12:55:24 +03:00
Gaith Hallak
80645222ad Allow accessing records fields in toplevel consts 2023-04-12 12:55:24 +03:00
Gaith Hallak
7d61d247f7 Report all invalid constant expressions before fail 2023-04-12 12:55:24 +03:00
Gaith Hallak
e64bdd40d2 Show empty map or record error when assigning to const 2023-04-12 12:55:24 +03:00
Gaith Hallak
77be5750f3 Add test for assigining constant to a constant 2023-04-12 12:55:24 +03:00
Gaith Hallak
aa8ae76aca Revert "Do not reverse constants declarations"
This reverts commit c4647fadacd134866e4be9c2ab4b0d54870a35fd.
2023-04-12 12:55:24 +03:00
Gaith Hallak
112e5338da Add test for accessing const from namespace 2023-04-12 12:55:24 +03:00
Gaith Hallak
c6bdb15693 Add tests for all valid expressions 2023-04-12 12:55:24 +03:00
Gaith Hallak
98c521d90a Do not reverse constants declarations 2023-04-12 12:55:24 +03:00
Gaith Hallak
a9548e77d8 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
2023-04-12 12:55:24 +03:00
Gaith Hallak
719dfdf240 Allow data constructors in compile-time constants 2023-04-12 12:55:24 +03:00
Gaith Hallak
cb817d6c76 Allow records to be used as compile time constants 2023-04-12 12:55:24 +03:00
Gaith Hallak
e438fbbaf4 Warn when shadowing a constant 2023-04-12 12:55:24 +03:00
Gaith Hallak
2dfe5eefb0 Remove the test that fails on toplevel consts 2023-04-12 12:55:24 +03:00
Gaith Hallak
49f73f8201 Allow compile-time constants as toplevel declarations 2023-04-12 12:55:24 +03:00