Skip to content

Commit ea8a6f1

Browse files
committed
Compile release notes
1 parent a2d7cca commit ea8a6f1

16 files changed

+244
-225
lines changed

docs/src/release_notes.md

+244
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,250 @@ Fe is moving fast. Read up on all the latest improvements.
1010
**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.**
1111

1212
[//]: # (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.
24+
25+
E.g.
26+
27+
```
28+
struct Signed {
29+
book_msg: String<100>
30+
}
31+
32+
contract GuestBook {
33+
messages: Map<address, String<100>>
34+
35+
pub fn sign(mut self, mut ctx: Context, book_msg: String<100>) {
36+
self.messages[ctx.msg_sender()] = book_msg
37+
ctx.emit(Signed(book_msg))
38+
}
39+
}
40+
```
41+
([#717](https://github.com/ethereum/fe/issues/717))
42+
43+
- 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)`
112+
* Boolean literal(`true` and `false`)
113+
* Enum variant. e.g., `MyEnum::Tuple(a, b, c)`
114+
* Tuple pattern. e.g., `(a, b, c)`
115+
* Struct pattern. e.g., `MyStruct {x: x1, y: y1, b: true}`
116+
* 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
174+
x += 1
175+
}
176+
```
177+
([#777](https://github.com/ethereum/fe/issues/777))
178+
- The contents of the `std::prelude` module (currently just the `Context` struct)
179+
are now automatically `use`d by every module, so `use std::context::Context` is
180+
no longer required. ([#779](https://github.com/ethereum/fe/issues/779))
181+
- When the Fe compiler generates a JSON ABI file for a contract, the
182+
"stateMutability" field for each function now reflects whether the function can
183+
read or modify chain or contract state, based on the presence or absence of the
184+
`self` and `ctx` parameters, and whether those parameters are `mut`able.
185+
186+
If a function doesn't take `self` or `ctx`, it's "pure".
187+
If a function takes `self` or `ctx` immutably, it can read state but not mutate
188+
state, so it's a "view"
189+
If a function takes `mut self` or `mut ctx`, it can mutate state, and is thus
190+
marked "payable".
191+
192+
Note that we're following the convention set by Solidity for this field, which
193+
isn't a perfect fit for Fe. The primary issue is that Fe doesn't currently
194+
distinguish between "payable" and "nonpayable" functions; if you want a function
195+
to revert when Eth is sent, you need to do it manually
196+
(eg `assert ctx.msg_value() == 0`). ([#783](https://github.com/ethereum/fe/issues/783))
197+
198+
- Trait associated functions
199+
200+
This change allows trait functions that do not take a `self` parameter.
201+
The following demonstrates a possible trait associated function and its usage:
202+
203+
```
204+
trait Max {
205+
fn max(self) -> u8;
206+
}
207+
208+
impl Max for u8 {
209+
fn max() -> u8 {
210+
return u8(255)
211+
}
212+
}
213+
214+
contract Example {
215+
216+
pub fn run_test(self) {
217+
assert u8::max() == 255
218+
}
219+
}
220+
```
221+
([#805](https://github.com/ethereum/fe/issues/805))
222+
223+
224+
### Bugfixes
225+
226+
227+
- Fix issue where calls to assiciated functions did not enforce visibility rules.
228+
229+
E.g the following code should be rejected but previously wasn't:
230+
231+
```
232+
struct Foo {
233+
fn do_private_things() {
234+
}
235+
}
236+
237+
contract Bar {
238+
fn test() {
239+
Foo::do_private_things()
240+
}
241+
}
242+
```
243+
244+
With this change, the above code is now rejected because `do_private_things` is not `pub`. ([#767](https://github.com/ethereum/fe/issues/767))
245+
- Padding on `bytes` and `string` ABI types is zeroed out. ([#769](https://github.com/ethereum/fe/issues/769))
246+
- Ensure traits from other modules or even ingots can be implemented ([#773](https://github.com/ethereum/fe/issues/773))
247+
- Certain cases where the compiler would not reject pure functions
248+
being called on instances are now properly rejected. ([#775](https://github.com/ethereum/fe/issues/775))
249+
- Reject calling `to_mem()` on primitive types in storage ([#801](https://github.com/ethereum/fe/issues/801))
250+
- Disallow importing private type via `use`
251+
252+
The following was previously allowed but will now error:
253+
254+
`use foo::PrivateStruct` ([#815](https://github.com/ethereum/fe/issues/815))
255+
256+
13257
## 0.19.1-alpha "Sunstone" (2022-07-06)
14258

15259

newsfragments/717.feature.md

-22
This file was deleted.

newsfragments/757.feature.md

-28
This file was deleted.

newsfragments/767.bugfix.md

-18
This file was deleted.

newsfragments/767.feature.md

-1
This file was deleted.

newsfragments/769.bugfix.md

-1
This file was deleted.

newsfragments/770.feature.md

-48
This file was deleted.

newsfragments/773.bugfix.md

-1
This file was deleted.

newsfragments/775.bugfix.md

-2
This file was deleted.

newsfragments/776.feature.md

-1
This file was deleted.

0 commit comments

Comments
 (0)