Spec: Are blocks allowed in patterns?
See original GitHub issueScalac doesn’t parse following programs syntactically, but support it if it’s synthesized.
Dotty accepts the code syntactically, but the typer generates a typing error.
object Test {
val a = (3, 4) match {
case ({name: Int}, {parent: Int}) => (name, parent)
}
val name = a._1
val parent = a._2
}
Error message:
-- Error: examples/block.scala -------------------------------------------------
6 | val name = a._1
| ^
| cyclic reference involving value a
-- Error: examples/block.scala -------------------------------------------------
7 | val parent = a._2
| ^
| cyclic reference involving value a
-- Error: examples/block.scala -------------------------------------------------
3 | case ({name: Int}, {parent: Int}) => (name, parent)
| ^^^^
| cyclic reference involving value a
three errors found
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Patterns | Block Editor Handbook
Block Patterns are predefined block layouts, available from the patterns tab of the block inserter. Once inserted into content, the blocks are ready...
Read more >Chapter 14. Blocks, Statements, and Patterns
Blocks are explained first (§14.2), both because they can appear in certain places where statements are not allowed and because one kind of...
Read more >Specification pattern and open closed principle
The Specification Pattern, as far as I understand it, is about creating complex business rules from small rule building blocks.
Read more >PEP 634 – Structural Pattern Matching: Specification
Irrefutable case blocks. A pattern is considered irrefutable if we can prove from its syntax alone that it will always succeed. In particular,...
Read more >ARIA Authoring Practices Guide | APG | WAI - W3C
This guide describes how to apply accessibility semantics to common design patterns and widgets. It provides design patterns and functional examples ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it would be good to allow this! Needs a spec change, though.
It seems like it would open up a lot of new and interesting possibilities, though I’m a little scared about what should and shouldn’t be allowed…