Glow-Lang / glow

The Glow language for Blockchain Decentralized Applications.
https://glow-lang.org
Apache License 2.0
58 stars 8 forks source link

Add constraints to examples in dapps/ needed to prevent overflow. #443

Open zenhack opened 2 years ago

zenhack commented 2 years ago

@marcinjangrzybowski asked me to come up with some examples of what index type constraints would look like in glow. This PR is a first step; it adds annotations that would become necessary for our existing apps in dapps/ to type check (and adds comments explaining what's going on). I'm pleased to see that it's already catching real bugs (if ones that are unlikely to come up in practice).

I'm going to mark this as a draft; we should not merge this, but it seemed like an easy way to get the diff in front of your eyes.

I plan to also look up some representative overflow exploits to see how this would apply to those as well.