plum

#treesitter#compiler#wasm

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
Files changed (1) hide show
  1. 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
- // A payload-less self-named single variant (`enum Array[T] = | Array`)
257
+ // A payload-less self-named single variant (`enum Array[T] = | Array`)
260
- // is an opaque builtin handle and stays legal.
258
+ // is an opaque builtin handle and stays legal.
261
- let opaque: Vec<String> = source
259
+ let opaque: Vec<String> = source
262
- .items
260
+ .items
263
- .iter()
261
+ .iter()
264
- .filter_map(|i| match i {
262
+ .filter_map(|i| match i {
265
- Item::Enum(e)
263
+ Item::Enum(e)
266
- if e.variants.len() == 1
264
+ if e.variants.len() == 1
267
- && e.variants[0].name == e.name
265
+ && e.variants[0].name == e.name
268
- && e.variants[0].fields.is_empty()
266
+ && e.variants[0].fields.is_empty()
269
- && e.variants[0].values.is_empty() =>
267
+ && e.variants[0].values.is_empty() =>
270
- {
268
+ {
271
- Some(format!(
269
+ Some(format!(
272
- "enum {0} has a single variant named {0} — write record {0}(...)",
270
+ "enum {0} has a single variant named {0} — write record {0}(...)",
273
- e.name
271
+ e.name
274
- ))
272
+ ))
275
- }
273
+ }
276
- _ => None,
274
+ _ => None,
277
- })
275
+ })
278
- .collect();
276
+ .collect();
279
- let legacy: Vec<String> = crate::unions::legacyErrors(source)
277
+ let legacy: Vec<String> = crate::unions::legacyErrors(source)
280
- .into_iter()
278
+ .into_iter()
281
- .filter(|m| !opaque.contains(m))
279
+ .filter(|m| !opaque.contains(m))
282
- .collect();
280
+ .collect();
283
- if !legacy.is_empty() {
281
+ if !legacy.is_empty() {
284
- return Err(legacy.join("\n"));
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()));