plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
fcb3865
— Peter John
2026-11-01T21:01:26+05:30
T9: drop Json legacy exemption
- plum-core/src/loader.rs +26 -29
plum-core/src/loader.rs
CHANGED
|
@@ -254,35 +254,32 @@ fn mergeItems(
|
|
|
254
254
|
prims: &mut Vec<PrimitiveDecl>,
|
|
255
255
|
) -> Result<(), String> {
|
|
256
256
|
// Removed forms (inline variant payloads, lone self-named variant).
|
|
257
|
-
// TODO(T9): remove Json exemption
|
|
258
|
-
if !file.to_string_lossy().ends_with("plum-std/Json.plum") {
|
|
259
|
-
|
|
257
|
+
// A payload-less self-named single variant (`enum Array[T] = | Array`)
|
|
260
|
-
|
|
258
|
+
// is an opaque builtin handle and stays legal.
|
|
261
|
-
|
|
259
|
+
let opaque: Vec<String> = source
|
|
262
|
-
|
|
260
|
+
.items
|
|
263
|
-
|
|
261
|
+
.iter()
|
|
264
|
-
|
|
262
|
+
.filter_map(|i| match i {
|
|
265
|
-
|
|
263
|
+
Item::Enum(e)
|
|
266
|
-
|
|
264
|
+
if e.variants.len() == 1
|
|
267
|
-
|
|
265
|
+
&& e.variants[0].name == e.name
|
|
268
|
-
|
|
266
|
+
&& e.variants[0].fields.is_empty()
|
|
269
|
-
|
|
267
|
+
&& e.variants[0].values.is_empty() =>
|
|
270
|
-
|
|
268
|
+
{
|
|
271
|
-
|
|
269
|
+
Some(format!(
|
|
272
|
-
|
|
270
|
+
"enum {0} has a single variant named {0} — write record {0}(...)",
|
|
273
|
-
|
|
271
|
+
e.name
|
|
274
|
-
|
|
272
|
+
))
|
|
275
|
-
|
|
273
|
+
}
|
|
276
|
-
|
|
274
|
+
_ => None,
|
|
277
|
-
|
|
275
|
+
})
|
|
278
|
-
|
|
276
|
+
.collect();
|
|
279
|
-
|
|
277
|
+
let legacy: Vec<String> = crate::unions::legacyErrors(source)
|
|
280
|
-
|
|
278
|
+
.into_iter()
|
|
281
|
-
|
|
279
|
+
.filter(|m| !opaque.contains(m))
|
|
282
|
-
|
|
280
|
+
.collect();
|
|
283
|
-
|
|
281
|
+
if !legacy.is_empty() {
|
|
284
|
-
|
|
282
|
+
return Err(legacy.join("\n"));
|
|
285
|
-
}
|
|
286
283
|
}
|
|
287
284
|
// Parse-time literal errors (out-of-range integers) of every merged file.
|
|
288
285
|
MERGED_LIT_ERRORS.with(|e| e.borrow_mut().extend(source.formErrors.iter().cloned()));
|