cashscript
cashscript copied to clipboard
Consider whether to allow typed `bytesX` function arguments
Created a standalone issue for typed bytesX function arguments
previously part of #178 (previously titled 'Consider changes to bytes types)
Mathieu and I were talking about this and we think it could make sense to disallow bytesX as function parameters, since these types are not runtime enforced. We could alternatively also add an option to enforce these types by injecting require(x.length === y) statements. This is something we should consider in more detail later.
For
bytesXtypes in function parameters:
- We disallow
bytesXas function argument.- If a user adds e.g. a
require(x.length == 20)check, then the compiler will infer thatx's type isbytes20for the rest of the contract.- (Optionally) apply the same for
ifstatements.- If people want to forgo these checks, they can always manually cast to
bytesX(x). We should add a warning to the docs about the security implications of doing that.
this issue also came up when thinking about how to integrate structs (#27)