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
{{ message }}
Repository navigation
Commit 0adcdad
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: compiler/src/check.rs
+14-16Lines changed: 14 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -211,6 +211,8 @@ struct Sym<'a> {
211
211
line:i64,
212
212
question:bool,
213
213
io:bool,
214
+
/// a fn's parameter: never a write target (O-4)
215
+
param:bool,
214
216
instantiating:bool,
215
217
params:Option<Vec<SigParam>>,
216
218
captures:Vec<SId>,
@@ -244,6 +246,7 @@ impl<'a> Sym<'a> {
244
246
line,
245
247
question:false,
246
248
io:false,
249
+
param:false,
247
250
instantiating:false,
248
251
params:None,
249
252
captures:vec![],
@@ -1105,8 +1108,8 @@ impl<'a> Checker<'a> {
1105
1108
self.err("DUPLICATE_DECLARATION","E-7",format!("{} is declared twice in one block", name));
1106
1109
}
1107
1110
let contract = if ty.as_ref().is_some_and(|t| ROW_WORDS.is_match(t)) || *exported {Some(contract_of(ty.as_deref()))}else{None};
1108
-
if*source && dflt.is_some(){
1109
-
self.err("INVALID_CONTEXT_DEFAULT","RG-7c",format!("context {}: source … has no default — a provided source is its provider's; a default would be one source every user writes (declare that source instead)", name));
1111
+
if*source {
1112
+
self.err("SOURCE_CONTEXT","O-4",format!("context {}: source … is withdrawn (RG-7c, 2026-10-31): what is provided is read beneath it — provide the writes you allow, as actions (`context {}: {{ current: T; set: (v: T) => void }}`)", name, name));
1110
1113
}
1111
1114
let suffix = ifself.regions[region].parent.is_some(){
self.provisions.push(Provision{key: info.key.clone(), e, env });
1697
-
if info.source{
1698
-
let t = ifletExprKind::Id(n) = &e.k{self.lookup(env, n)}else{None};
1699
-
if t.is_none_or(|t| self.syms[t].kind != SymKind::Source || self.syms[t].imported.is_some()){
1700
-
self.err("PROVIDE_NOT_A_SOURCE","RG-7c",format!("context {} carries a source: provide one of this module's sources by name (`provide {} = x`)", name, name));
1701
-
}
1702
-
}
1703
1700
ifletSome(contract) = info.contract{
1704
1701
let line = self.line;
1705
1702
self.later.push(Later::Provide{name: name.clone(), e, env, line, contract });
format!("context {} is not declared `source`: what is provided is read-only (`context {}: source T` to write through it)", target.name, target.name),
2330
-
);
2327
+
self.err("WRITE_TO_NON_SOURCE","O-4",format!("context {} is read beneath its provision: call an action it provides that writes it (O-4)", target.name));
2331
2328
}
2332
2329
}
2333
2330
}else{
@@ -2341,7 +2338,8 @@ impl<'a> Checker<'a> {
2341
2338
SymKind::Props => "props".to_string(),
2342
2339
k => format!("a {}", k.as_str()),
2343
2340
};
2344
-
self.err("WRITE_TO_NON_SOURCE","W-1",format!("{} is {}: only sources are written (W-1)", target.name, what));
2341
+
let hint = if k == SymKind::Props || k == SymKind::Value || self.syms[t].param{" — a source is written only in the region that declares it: have its owner pass an action that writes it (O-4)"}else{""};
2342
+
self.err("WRITE_TO_NON_SOURCE","W-1",format!("{} is {}: only sources are written (W-1){}", target.name, what, hint));
0 commit comments