plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


805d96dPeter John 2026-08-09T21:07:14+05:30
test: migrate plum-checker/plum-wasm-codegen fixtures off <Receiver> syntax
examples/methods.plum CHANGED
@@ -2,18 +2,18 @@ type Cat =
2
2
  name: Str
3
3
  age: Int
4
4
 
5
- fun getAge<Cat>(self) -> Int =
5
+ fun getAge(self) -> Int =
6
- self.age
6
+ self.age
7
7
 
8
- fun birthday<Cat>(self) -> Int =
8
+ fun birthday(self) -> Int =
9
- self.age + 1
9
+ self.age + 1
10
10
 
11
11
  type Wrapper =
12
12
  inner: Cat
13
13
  tag: Int
14
14
 
15
- fun innerAge<Wrapper>(self) -> Int =
15
+ fun innerAge(self) -> Int =
16
- self.inner.age
16
+ self.inner.age
17
17
 
18
18
  fun makeCat() -> Cat =
19
19
  Cat(name: "Whiskers", age: 3)
plum-checker/tests/checker_tests.rs CHANGED
@@ -101,7 +101,7 @@ fn bool_literal_wrong_return_type_is_error() {
101
101
 
102
102
  #[test]
103
103
  fn method_self_field_access_passes() {
104
- let src = "type Cat =\n name: Str\n age: Int\n\nfun getName<Cat>() -> Str =\n self.name\n";
104
+ let src = "type Cat =\n name: Str\n age: Int\n\n fun getName() -> Str =\n self.name\n";
105
105
  let source = parse(src);
106
106
  let result = check_source(&source);
107
107
  assert!(result.is_ok(), "expected Ok, got {:?}", result.err());
@@ -116,21 +116,16 @@ fn method_self_unknown_field_is_error() {
116
116
  }
117
117
 
118
118
  #[test]
119
- fn nested_method_type_checks_identically_to_top_level_receiver_form() {
119
+ fn nested_method_type_checks() {
120
- let nested_src = "type Cat =\n name: Str\n age: Int\n\n fun getName(self) -> Str =\n self.name\n";
120
+ let src = "type Cat =\n name: Str\n age: Int\n\n fun getName(self) -> Str =\n self.name\n";
121
- let top_level_src = "type Cat =\n name: Str\n age: Int\n\nfun getName<Cat>() -> Str =\n self.name\n";
122
- let nested_result = check_source(&parse(nested_src));
121
+ let result = check_source(&parse(src));
123
- let top_level_result = check_source(&parse(top_level_src));
124
- assert!(nested_result.is_ok(), "expected Ok, got {:?}", nested_result.err());
122
+ assert!(result.is_ok(), "expected Ok, got {:?}", result.err());
125
- assert!(top_level_result.is_ok(), "expected Ok, got {:?}", top_level_result.err());
126
123
  }
127
124
 
128
125
  #[test]
129
- fn nested_method_unknown_field_is_error_identically_to_top_level_receiver_form() {
126
+ fn nested_method_unknown_field_is_error() {
130
- let nested_src = "type Cat =\n name: Str\n\n fun getAge(self) -> Int =\n self.age\n";
127
+ let src = "type Cat =\n name: Str\n\n fun getAge(self) -> Int =\n self.age\n";
131
- let top_level_src = "type Cat =\n name: Str\n\nfun getAge<Cat>() -> Int =\n self.age\n";
132
- assert!(check_source(&parse(nested_src)).is_err());
128
+ assert!(check_source(&parse(src)).is_err());
133
- assert!(check_source(&parse(top_level_src)).is_err());
134
129
  }
135
130
 
136
131
  #[test]
@@ -705,8 +700,8 @@ type Cat =
705
700
  name: Str
706
701
  age: Int
707
702
 
708
- fun haveBirthday<Cat>() =
703
+ fun haveBirthday() =
709
- self.age = self.age + 1
704
+ self.age = self.age + 1
710
705
  ";
711
706
  let source = parse(src);
712
707
  assert!(check_source(&source).is_ok(), "expected Ok");
plum-wasm-codegen/tests/codegen_tests.rs CHANGED
@@ -150,8 +150,8 @@ type Cat =
150
150
  name: Str
151
151
  age: Int
152
152
 
153
- fun getAge<Cat>() -> Int =
153
+ fun getAge() -> Int =
154
- self.age
154
+ self.age
155
155
 
156
156
  fun makeCat() -> Int =
157
157
  c = Cat(name: \"x\", age: 3)
@@ -391,8 +391,8 @@ type Cat =
391
391
  name: Str
392
392
  age: Int
393
393
 
394
- fun getAge<Cat>() -> Int =
394
+ fun getAge() -> Int =
395
- self.age
395
+ self.age
396
396
 
397
397
  fun main() -> Int =
398
398
  c = Cat(name: \"x\", age: 7)
@@ -759,12 +759,12 @@ enum Option =
759
759
  type Box =
760
760
  value: Option
761
761
 
762
- fun unwrap<Box>(default: Int) -> Int =
762
+ fun unwrap(default: Int) -> Int =
763
- match self.value
763
+ match self.value
764
- Some(v) =>
764
+ Some(v) =>
765
- return v
765
+ return v
766
- None =>
766
+ None =>
767
- return default
767
+ return default
768
768
 
769
769
  fun main() -> Int =
770
770
  b = Box(value: Some(42))
@@ -913,8 +913,8 @@ fn generic_class_specialized_at_two_types_does_not_alias() {
913
913
  type Box[T] =
914
914
  value: T
915
915
 
916
- fun getIntValue<Box>() -> Int =
916
+ fun getIntValue() -> Int =
917
- self.value
917
+ self.value
918
918
 
919
919
  fun useInt() -> Int =
920
920
  b = Box(value: 7)
@@ -948,8 +948,8 @@ fn generic_method_on_generic_class_runs_correctly() {
948
948
  type Box[T] =
949
949
  value: T
950
950
 
951
- fun getValue<Box>() -> Int =
951
+ fun getValue() -> Int =
952
- self.value
952
+ self.value
953
953
 
954
954
  fun main() -> Int =
955
955
  b = Box(value: 9)
@@ -1067,8 +1067,8 @@ fn ordinary_function_with_bare_generic_class_param_runs_correctly() {
1067
1067
  type Box[T] =
1068
1068
  value: T
1069
1069
 
1070
- fun getBoxValue<Box>() -> Int =
1070
+ fun getBoxValue() -> Int =
1071
- self.value
1071
+ self.value
1072
1072
 
1073
1073
  fun sumBox(b: Box) -> Int =
1074
1074
  b.getBoxValue()
@@ -1433,8 +1433,8 @@ fn field_assignment_target_runs_correctly() {
1433
1433
  type Counter =
1434
1434
  value: Int
1435
1435
 
1436
- fun bump<Counter>() =
1436
+ fun bump() =
1437
- self.value = self.value + 1
1437
+ self.value = self.value + 1
1438
1438
 
1439
1439
  fun main() -> Int =
1440
1440
  c = Counter(value: 41)
@@ -1455,8 +1455,8 @@ type Inner =
1455
1455
  type Outer =
1456
1456
  inner: Inner
1457
1457
 
1458
- fun bump<Outer>() =
1458
+ fun bump() =
1459
- self.inner.value = self.inner.value + 1
1459
+ self.inner.value = self.inner.value + 1
1460
1460
 
1461
1461
  fun main() -> Int =
1462
1462
  o = Outer(inner: Inner(value: 9))