Skip to content

v0.15.0-alpha "Onyx"

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 04 Apr 15:30
· 351 commits to master since this release
316e6aa

WARNING: All Fe releases are alpha releases and only meant to share the development progress with developers and enthusiasts. It is NOT yet ready for production usage.

0.15.0-alpha "Onyx" (2022-04-04)

Features

  • Labels are now required on function arguments. Labels can be omitted if the
    argument is a variable with a name that matches the label, or if the function
    definition specifies that an argument should have no label. Functions often take
    several arguments of the same type; compiler-checked labels can help prevent
    accidentally providing arguments in the wrong order.

    Example:

    contract CoolCoin:
      balance: Map<address, i256>
      loans: Map<(address, address), i256>
    
      pub fn demo(self, ann: address, bob: address):
        let is_loan: bool = false
        self.give(from: ann, to: bob, 100, is_loan)
    
      fn transfer(self, from sender: address, to recipient: address, _ val: u256, is_loan: bool):
        self.cred[sender] -= val
        self.cred[recipient] += val
        if is_loan:
          self.loans[(sender, recipient)] += val
    

    Note that arguments must be provided in the order specified in the function
    definition.

    A parameter's label defaults to the parameter name, but can be changed by
    specifying a different label to the left of the parameter name. Labels should be
    clear and convenient for the caller, while parameter names are only used in the
    function body, and can thus be longer and more descriptive.
    In the example above, we choose to use sender and recipient as identifiers
    in the body of fn transfer, but use labels from: and to:.

    In cases where it's ideal to not have labels, e.g. if a function takes a single
    argument, or if types are sufficient to differentiate between arguments, use _
    to specify that a given parameter has no label. It's also fine to require labels
    for some arguments, but not others.

    Example:

    fn add(_ x: u256, _ y: u256) -> u256:
      return x + y
    
    contract Foo:
      fn transfer(self, _ to: address, wei: u256):
        pass
    
      pub fn demo(self):
        transfer(address(0), wei: add(1000, 42))
    

(#397)

Bugfixes

  • The region of memory used to compute the slot of a storage map value was not being allocated. (#684)