You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/release_notes.md
+244
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,250 @@ Fe is moving fast. Read up on all the latest improvements.
10
10
**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.**
11
11
12
12
[//]: #(towncrier release notes start)
13
+
## 0.20.0-alpha (2022-12-05)
14
+
15
+
16
+
### Features
17
+
18
+
19
+
- Removed the `event` type as well as the `emit` keyword.
20
+
Instead the `struct` type now automatically implements
21
+
the `Emittable` trait and can be emitted via `ctx.emit(..)`.
22
+
23
+
Indexed fields can be annotated via the `#indexed` attribute.
- Allow to call trait methods on types when trait is in scope
44
+
45
+
So far traits were only useful as bounds for generic functions.
46
+
With this change traits can also be used as illustrated with
47
+
the following example:
48
+
49
+
```
50
+
trait Double {
51
+
fn double(self) -> u256;
52
+
}
53
+
54
+
impl Double for (u256, u256) {
55
+
fn double(self) -> u256 {
56
+
return (self.item0 + self.item1) * 2
57
+
}
58
+
}
59
+
60
+
contract Example {
61
+
62
+
pub fn run_test(self) {
63
+
assert (0, 1).double() == 2
64
+
}
65
+
}
66
+
```
67
+
68
+
If a call turns out to be ambigious the compiler currently asks the
69
+
user to disambiguate via renaming. In the future we will likely
70
+
introduce a syntax to allow to disambiguate at the callsite. ([#757](https://github.com/ethereum/fe/issues/757))
71
+
72
+
- Allow contract associated functions to be called via `ContractName::function_name()` syntax. ([#767](https://github.com/ethereum/fe/issues/767))
73
+
- Add `enum` types and `match` statement.
74
+
75
+
`enum` can now be defined, e.g.,
76
+
77
+
```fe
78
+
pub enum MyEnum {
79
+
Unit
80
+
Tuple(u32, u256, bool)
81
+
82
+
fn unit() -> MyEnum {
83
+
return MyEnum::Unit
84
+
}
85
+
}
86
+
```
87
+
88
+
Also, `match` statement is introduced, e.g.,
89
+
90
+
```fe,ignore
91
+
pub fn eval_enum() -> u256{
92
+
match MyEnum {
93
+
MyEnum::Unit => {
94
+
return 0
95
+
}
96
+
97
+
MyEnum::Tuple(a, _, false) => {
98
+
return u256(a)
99
+
}
100
+
101
+
MyEnum::Tuple(.., true) => {
102
+
return u256(1)
103
+
}
104
+
}
105
+
}
106
+
```
107
+
108
+
109
+
For now, available patterns are restricted to
110
+
* Wildcard(`_`), which matches all patterns: `_`
111
+
* Named variable, which matches all patterns and binds the value to make the value usable in the arm. e.g., `a`, `b` and `c` in `MyEnum::Tuple(a, b, c)`
* Rest pattern(`..`), which matches the rest of the pattern. e.g., `MyEnum::Tuple(.., true)`
117
+
* Or pattern(|). e.g., MyEnum::Unit | MyEnum::Tuple(.., true)
118
+
119
+
Fe compiler performs the exhaustiveness and usefulness checks for `match` statement.
120
+
So the compiler will emit an error when all patterns are not covered or an unreachable arm are detected. ([#770](https://github.com/ethereum/fe/issues/770))
121
+
- Changed comments to use `//` instead of `#` ([#776](https://github.com/ethereum/fe/issues/776))
122
+
- Added the `mut` keyword, to mark things as mutable. Any variable or function parameter
123
+
not marked `mut` is now immutable.
124
+
125
+
```fe
126
+
contract Counter {
127
+
count: u256
128
+
129
+
pub fn increment(mut self) -> u256 {
130
+
// `self` is mutable, so storage can be modified
131
+
self.count += 1
132
+
return self.count
133
+
}
134
+
}
135
+
136
+
struct Point {
137
+
pub x: u32
138
+
pub y: u32
139
+
140
+
pub fn add(mut self, _ other: Point) {
141
+
self.x += other.x
142
+
self.y += other.y
143
+
144
+
// other.x = 1000 // ERROR: `other` is not mutable
145
+
}
146
+
}
147
+
148
+
fn pointless() {
149
+
let origin: Point = Point(x: 0, y: 0)
150
+
// origin.x = 10 // ERROR: origin is not mutable
151
+
152
+
let x: u32 = 10
153
+
// x_coord = 100 // ERROR: `x_coord` is not mutable
154
+
let mut y: u32 = 0
155
+
y = 10 // OK
156
+
157
+
let mut p: Point = origin // copies `origin`
158
+
p.x = 10 // OK, doesn't modify `origin`
159
+
160
+
let mut q: Point = p // copies `p`
161
+
q.x = 100 // doesn't modify `p`
162
+
163
+
p.add(q)
164
+
assert p.x == 110
165
+
}
166
+
```
167
+
168
+
Note that, in this release, primitive type function parameters
169
+
can't be `mut`. This restriction might be lifted in a future release.
170
+
171
+
For example:
172
+
```fe,ignore
173
+
fn increment(mut x: u256) { // ERROR: primitive type parameters can't be mut
0 commit comments