Skip to content

Commit

Permalink
refactor(rivet): rename special method __drop__ to __destroy__
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 1, 2024
1 parent eb5f72c commit e92f02f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/core/src/DynArray.ri
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct DynArray {
return dyn_array;
}

func __drop__(self) {
func __destroy__(self) {
unsafe {
mem_dealloc(self.ptr);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/string.c.ri
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ pub struct string < Stringable, Hashable, Throwable {
return self > rhs || self == rhs;
}

func __drop__(self) {
func __destroy__(self) {
if !self.is_ref {
unsafe {
mem_dealloc(self.ptr);
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/checker/decls.ri
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ extend Checker {
);
}
match func_decl.name {
"__drop__" -> {},
"__destroy__" -> {},
else -> report.error(
"unknown special method `{}`".fmt(func_decl.name),
func_decl.pos
Expand Down
2 changes: 1 addition & 1 deletion lib/std/src/dynlib/mod.c.ri
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct Library {
_ = unsafe { libc.dlclose(self.ptr) };
}

func __drop__(self) {
func __destroy__(self) {
self.close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/invalid/directly_call_a_special_method.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/invalid/directly_call_a_special_method.ri:9:5: error: cannot call a special method directly
9 | d.__drop__();
| ^~~~~~~~~~~~
9 | d.__destroy__();
| ^~~~~~~~~~~~~~~
rivet: error: could not compile module `directly_call_a_special_method`, aborting due to previous error
8 changes: 4 additions & 4 deletions tests/invalid/directly_call_a_special_method.ri
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
struct Dropper {
func __drop__(self) {
struct Destroyer {
func __destroy__(self) {
_ = self;
}
}

func main() {
d := Dropper();
d.__drop__();
d := Destroyer();
d.__destroy__();
}
2 changes: 1 addition & 1 deletion tests/valid/src/special_methods.ri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct SpecialMethods {
func __drop__(self) {
func __destroy__(self) {
_ = self;
}
}

0 comments on commit e92f02f

Please sign in to comment.