SpyglassMC / Spyglass

Development tools for vanilla Minecraft: Java Edition data pack developers.
https://spyglassmc.com
MIT License
273 stars 29 forks source link

Add `cmp` mcdoc attribute #1348

Open misode opened 2 weeks ago

misode commented 2 weeks ago

This attribute should allow us to compare two fields in a struct, something like this:

#[cmp(left=[[min]],op="<=",right=[[max]])]
struct Foo {
  min?: int,
  max?: int,
}
SPGoding commented 2 weeks ago

what if (I'm mostly trolling)

struct Foo {
   min?: int @ ..[[max]],
   max?: int @ [[min]]..,
}
misode commented 2 weeks ago

Being able to specify ranges using types would help us with generics as well tbh...

type Foo<A> = struct {
  min: int @ 0..A,
}

But yeah maybe that'd make it a bit too complicated