Skip to content

Commit 8c0e910

Browse files
wip
1 parent ac825ae commit 8c0e910

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

docs/blog/_posts/2019-05-24-15th-dotty-milestone-release.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ def f(x: Int) given (y: String) (z: Int) = x + z
8989
f(1)(3)
9090
```
9191

92-
Now, however, `given` clauses must come last:
92+
Now, however, `given` clauses must come last. The above code will fail with:
93+
94+
```
95+
-- Error: ../issues/Playground.scala:3:34 --------------------------------------
96+
3 | def f(x: Int) given (y: String) (z: Int) = x + z
97+
| ^
98+
| normal parameters cannot come after `given' clauses
99+
one error found
100+
```
101+
102+
The following code is the correct way to express the program in question:
93103

94104
```scala
95105
implied for String = "foo"
@@ -118,7 +128,10 @@ Dotty compiler will allow such a pattern binding only if the pattern is *irrefut
118128
If we want to force the pattern binding if the pattern is not irrefutable, we can do so with an annotation:
119129

120130
```scala
121-
val first :: rest : @unchecked = elems // OK
131+
scala> val xs: List[Any] = List("1", "2", "3")
132+
| val (x: String) :: _: @unchecked = xs
133+
val x: String = 1
134+
val xs: List[Any] = List(1, 2, 3)
122135
```
123136

124137
The same is implemented for pattern bindings in `for` expressions:
@@ -131,13 +144,13 @@ The same is implemented for pattern bindings in `for` expressions:
131144

132145
For the migration purposes, the above change will only take effect in Dotty 3.1 by default. You can use it from Dotty 3 with the `-strict` flag.
133146

147+
For more information, see the [documentation](http://dotty.epfl.ch/docs/reference/changed-features/pattern-bindings.html).
134148

135-
## Other changes
136149

137-
Some of the other changes include:
150+
## Other changes
151+
Some of the other notable changes include:
138152

139-
- `infer` method renamed to `the`, the semantics of which is now the same as that of the `the` method of Shapeless. Namely, the implicits are resolved more precisely – see this [gist](https://gist.github.com/milessabin/8833a1dbf7e8245b30f8) for an example in Shapeless, and the Dotty [documentation](http://dotty.epfl.ch/docs/reference/contextual/inferable-params.html#querying-implied-instances) for more details.
140-
- The syntax of quoting and splicing was changed. Now the quoting is expressed via `'{ ... }` and `'[...]` and splicing – via `${...}` and `$id`. Please see the [documentation](http://dotty.epfl.ch/docs/reference/other-new-features/principled-meta-programming.html) for more details on these features.
153+
- Dotty is now fully B
141154

142155
# Let us know what you think!
143156

0 commit comments

Comments
 (0)