Skip to content

Commit

Permalink
Reword and improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
azdavis committed Aug 29, 2023
1 parent 6097211 commit c0cb38a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions docs/diagnostics/5001.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ val f = filter
(** + undefined value: `filter` *)
```

Confusingly, come functions like `map` are defined both in `List` and also aliased the top level.
Confusingly, some functions like `map` are defined both in `List` and also aliased the top level.

```sml
val m1 = List.map
Expand Down Expand Up @@ -65,20 +65,22 @@ val y : x = 5

### Check signature ascription

The name may be explicitly not permitted to be accessed outside of a structure due to a signature ascription.

Ascribing a structure to a more restrictive signature prohibits accessing the "extra" items inside the structure.
If the name is defined inside a structure, but the structure ascribes to a signature, and the signature does not include that name, then the name will not be available outside of the structure.

```sml
signature SIG = sig
val foo : int
val inSigAndStruct : int
end
structure Str : SIG = struct
val foo = 3
val bar = "hi"
val notInSig = "hi"
val inSigAndStruct = String.size notInSig
end
val s = Str.bar
(** ^^^^^^^ undefined value: `bar` *)
(* this is fine *)
val n = Str.inSigAndStruct
(* this is not *)
val s = Str.notInSig
(** ^^^^^^^^^^^^ undefined value: `notInSig` *)
```

0 comments on commit c0cb38a

Please sign in to comment.