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: rfcs/0000-changes-lifecyle.md
+86-50Lines changed: 86 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,31 +43,29 @@ A breaking change is a difference in functionality from the previous version of
43
43
44
44
The following changes are defined to be breaking changes, and will need to follow the process of being gated by features flags.
45
45
46
-
1 - Code without deprecated warning to be flagged as error;
47
-
2 - ABI json properties to be removed or have their type changed;
48
-
3 - Binary encoding that will break how SDK (and others) communicate with the compiler, that includes
49
-
50
-
- How scripts/predicates accept arguments on `main`;
51
-
- How scripts/predicates return data from `main`;
52
-
- How the `contract method selector` is encoded;
53
-
- How `contract method` arguments are encoded;
54
-
- How `log` data is encoded;
55
-
- How `message` data is encoded;
56
-
57
-
4 - Utilization of new VM opcodes;
58
-
5 - IR changes
59
-
6 - Receipt parsers to break;
60
-
7 - When a compiler feature or a standard library produce different behavior for the same code (semantic changes);
46
+
1. Code without deprecated warning to be flagged as error;
47
+
2. ABI json properties to be removed or have their type changed;
48
+
3. Binary encoding that will break how SDK (and others) communicate with the compiler, that includes
49
+
- How scripts/predicates accept arguments on `main`;
50
+
- How scripts/predicates return data from `main`;
51
+
- How the `contract method selector` is encoded;
52
+
- How `contract method` arguments are encoded;
53
+
- How `log` data is encoded;
54
+
- How `message` data is encoded;
55
+
4. Utilization of new VM opcodes;
56
+
5. IR changes
57
+
6. Receipt parsers to break;
58
+
7. When a compiler feature or a standard library produce different behavior for the same code (semantic changes);
61
59
62
60
## Feature flags
63
61
64
62
Any complex change that needed to be gated will need the following steps.
65
63
66
-
1 - A specific github issue labeled with `feature-*` and `track-feature`. This issue should be the umbrella for everything related with this feature;
67
-
2 - A preliminary PR enabling the feature flag should be created and linked in to the umbrella issue; This PR will enable the feature flag `--experimental <comma-separated-list>` on all tools.
68
-
3 - As many PRs will be created and merged an normal;
69
-
4 - When the feature is ready, a closing PR will be created and wait until the feature flag is enabled by default.
70
-
5 - On a later date, the feature flag can be removed making the feature the default behavior of the compiler.
64
+
1. A specific github issue labeled with `feature-*` and `track-feature`. This issue should be the umbrella for everything related with this feature;
65
+
2. A preliminary PR enabling the feature flag should be created and linked in to the umbrella issue; This PR will enable the feature flag `--experimental <comma-separated-list>` on all tools.
66
+
3. As many PRs will be created and merged an normal;
67
+
4. When the feature is ready, a closing PR will be created and wait until the feature flag is enabled by default.
68
+
5. On a later date, the feature flag can be removed making the feature the default behavior of the compiler.
These flags also need to be enabled programmatically by any compiler driver, like tests.
87
91
88
92
Unlike `Rust` we will not support features inside sway code like the example below, because some features will span across multiple tools. That would demand `forc` to parse, or ask the `sway` compiler if a feature is enabled or not.
@@ -97,6 +101,29 @@ Unlike `Rust` we will not support features inside sway code like the example bel
97
101
98
102
This section contains the suggested guide on how to introduce changes into different parts of the compiler and associated tools.
99
103
104
+
## `sway-features` crate
105
+
106
+
A new crate named `sway-features` will be created and will contains **ALL** features and its metadata. Best suggestion is a macro do define features where enums, documentation etc... will be generated.
107
+
108
+
This macro also needs to generate code for the errors and warnings related to each error.
109
+
110
+
Features will be parsed in this order:
111
+
112
+
```rust
113
+
letmutfeatures=ExperimentalFeatures::default();
114
+
features.parse_from_toml();
115
+
features.parse_from_cli();
116
+
features.parse_from_environment_variables();
117
+
```
118
+
119
+
Which means that environment variables overwrite cli arguments, which overwrite toml configuration.
120
+
121
+
If a feature requires or allow new configurations, these configurations should be optional, and as soon is confirmed the feature is enabled, it should verify if the required configuration is available.
To allow as user friendly error messages as possible, in all possible cases we want both lexer and parser to parse the new syntax even with the feature off.
@@ -105,39 +132,45 @@ After that, lexer, parser will mark that a experimental feature was lexed/parsed
105
132
106
133
The error message will have a message explaining that feature is experimental and a github link for more details on the stabilization lifecycle.
When formatting does not depend on a flag, formatting should always format new syntax, even when the flag is off. To avoid breaking other parts of the code, or even worst, removing code.
145
+
Formatting should always format new syntax, even when the flag is off. To avoid breaking other parts of the code, or even worst, removing code.
111
146
112
147
## LSP
113
148
114
149
LSP can take advantage of specific error messages, and suggest user to enable the corresponding feature.
115
150
116
-
## TODO
151
+
## CST, AST and Typed Tree
117
152
118
-
3 - Lexer?
119
-
4 - Parser?
120
-
5 - CST?
121
-
6 - AST?
122
-
7 - Typed Tree
123
-
8 - LSP
124
-
9 - Forc and plugins
125
-
10 - swayfmt
126
-
11 - New error
153
+
All tree must always support new features, which means that new nodes will always exist. Their specific behavior, desugaring etc... will be gated by the experimental feature.
154
+
155
+
More specifically, this means that variants should not be behind compiler flags.
127
156
128
157
# Drawbacks
129
158
130
159
[drawbacks]: #drawbacks
131
160
132
-
Why should we _not_ do this?
161
+
This will increase complexity of the compiler. Not all flags used to compile end up in the JSON ABI, or other outputs. Which can make reproducibility harder.
1 - In files inside the repo? - Saving in files sounds the best approach, but if we use the same file, all PRs will conflict. To avoid this we can do like `changeset` and use random names.
171
-
2 - In github PR descriptions? - This is the easiest approach, but it can be cumbersome to recover these messages.
172
-
3 - In git commit messages? - Given that the commit message is "created" when the PR is merged, there is no way to guarantee that "release notes" will exist or be "parseable" when we need them.
203
+
204
+
1. In files inside the repo? - Saving in files sounds the best approach, but if we use the same file, all PRs will conflict. To avoid this we can do like `changeset` and use random names.
205
+
2. In github PR descriptions? - This is the easiest approach, but it can be cumbersome to recover these messages.
206
+
3. In git commit messages? - Given that the commit message is "created" when the PR is merged, there is no way to guarantee that "release notes" will exist or be "parseable" when we need them.
207
+
-https://git-cliff.org/
173
208
174
209
Should new warnings be considered breaking changes?
175
-
1 - Normally warnings should not be considered breaking changes, because they do not break anything.
176
-
2 - But on the other hand, if the team treat warnings as errors, new warnings will break CIs, and demand
177
-
developers attention. Not all fixes are trivial, and can demand bigger code changes than the user would expect
178
-
from a minor update from the compiler.
210
+
211
+
1. Normally warnings should not be considered breaking changes, because they do not break anything.
212
+
2. But on the other hand, if the team treat warnings as errors, new warnings will break CIs, and demand
213
+
developers attention. Not all fixes are trivial, and can demand bigger code changes than the user would expect
0 commit comments