Skip to content

Commit

Permalink
doc: fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-jerry-ye committed Dec 16, 2024
1 parent dc27cf5 commit 50afe8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions next/language/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ trait Compare : Eq {
}
trait Hash {
hash(Self) -> Int
hash_combine(Self, Hasher) -> Unit // to be implemented
hash(Self) -> Int // has default implementation
}
trait Show {
// writes a string representation of `Self` into a `Logger`
output(Self, Logger) -> Unit
to_string(Self) -> String
output(Self, Logger) -> Unit // to be implemented
to_string(Self) -> String // has default implementation
}
trait Default {
Expand Down
18 changes: 11 additions & 7 deletions next/language/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,24 @@ Access control in MoonBit adheres to the principle that a `pub` type, function,

<!-- MANUAL CHECK -->
```moonbit
pub struct S {
pub(all) type T1
pub(all) type T2
priv type T3
pub(all) struct S {
x: T1 // OK
y: T2 // OK
z: T3 // ERROR: public field has private type `T3`!
}
// ERROR: public function has private parameter type `T3`!
pub fn f1(_x: T3) -> T1 { T1::A(0) }
pub fn f1(_x: T3) -> T1 { ... }
// ERROR: public function has private return type `T3`!
pub fn f2(_x: T1) -> T3 { T3::A(0) }
pub fn f2(_x: T1) -> T3 { ... }
// OK
pub fn f3(_x: T1) -> T1 { T1::A(0) }
pub fn f3(_x: T1) -> T1 { ... }
pub let a: T3 // ERROR: public variable has private type `T3`!
pub let a: T3 = { ... } // ERROR: public variable has private type `T3`!
```

## Access control of methods and trait implementations
Expand Down Expand Up @@ -125,11 +129,11 @@ trait Number {
op_sub(Self, Self) -> Self
}
fn add[N : Number](x : X, y: X) -> X {
fn add[N : Number](x : N, y: N) -> N {
Number::op_add(x, y)
}
fn sub[N : Number](x : X, y: X) -> X {
fn sub[N : Number](x : N, y: N) -> N {
Number::op_sub(x, y)
}
Expand Down

0 comments on commit 50afe8c

Please sign in to comment.