question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spec: Are blocks allowed in patterns?

See original GitHub issue

Scalac 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:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oderskycommented, Dec 11, 2016

I think it would be good to allow this! Needs a spec change, though.

0reactions
propensivecommented, Jan 19, 2018

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found