Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 2.13.4 '-Xlint:strict-unsealed-patmat' compiler flag #2295

Open
Christewart opened this issue Nov 26, 2020 · 1 comment
Open

Scala 2.13.4 '-Xlint:strict-unsealed-patmat' compiler flag #2295

Christewart opened this issue Nov 26, 2020 · 1 comment

Comments

@Christewart
Copy link
Contributor

Scala 2.13.4 adds a new compiler flag called

-Xlint:strict-unsealed-patmat

scala/scala#9299

You can see this branch as an example of enabling it

https://github.com/Christewart/bitcoin-s-core/tree/2020-11-26-strict-unsealed-patmat

Currently we have a bunch of errors when enabling this flag

sbt:bitcoin-s> core/compile
[info] Formatting 258 Scala sources...
[info] compiling 258 Scala sources to /home/suredbits/dev/bitcoin-s/core/target/scala-2.13/classes ...
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/api/wallet/db/AddressDb.scala:130:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.hd.HDPath forSome x not in (org.bitcoins.core.hd.LegacyHDPath, org.bitcoins.core.hd.NestedSegWitHDPath, org.bitcoins.core.hd.SegWitHDPath))
[error] path match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/bloom/BloomFilter.scala:233:7: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] constantsWithIndex match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/consensus/Merkle.scala:38:5: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] transactions match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/consensus/Merkle.scala:60:5: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] subTrees match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/p2p/NetworkPayload.scala:205:21: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] val hashesStr = hashes match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/protocol/blockchain/PartialMerkleTree.scala:73:11: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] subTree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/protocol/blockchain/PartialMerkleTree.scala:124:7: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] subTree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/protocol/transaction/InputUtil.scala:51:7: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] remaining match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/protocol/transaction/TxUtil.scala:71:7: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] remaining match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/serializers/script/ScriptParser.scala:76:25: match may not be exhaustive.
[error] bytes.size match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:11:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] this match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:18:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] this match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:25:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] this match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:41:7: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] tree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:62:7: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] subTree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:100:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] parentTree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:115:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] parentTree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:128:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] parentTree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BinaryTree.scala:146:7: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.util.BinaryTree[?] forSome x not in (Empty, org.bitcoins.core.util.Leaf[?], org.bitcoins.core.util.Node[?]))
[error] tree match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BitcoinScriptUtil.scala:191:7: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] tokens match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/util/BitcoinScriptUtil.scala:553:7: match may not be exhaustive.
[error] It would fail on the following input: (x: Seq[?] forSome x not in Nil)
[error] remainingSigs match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/wallet/utxo/InputSigningInfo.scala:49:5: match may not be exhaustive.
[error] It would fail on the following input: (x: InputType forSome x not in (org.bitcoins.core.wallet.utxo.P2SHNestedSegwitV0InputInfo, org.bitcoins.core.wallet.utxo.P2SHNonSegwitInputInfo, org.bitcoins.core.wallet.utxo.RawInputInfo, org.bitcoins.core.wallet.utxo.SegwitV0NativeInputInfo, org.bitcoins.core.wallet.utxo.UnassignedSegwitNativeInputInfo))
[error] inputInfo match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/wallet/utxo/InternalAddressTag.scala:86:9: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.wallet.utxo.AddressTagName forSome x not in (ColdStorageName, DeepColdStorageName, HotStorageName, org.bitcoins.core.wallet.utxo.UnknownAddressTagName))
[error] tagName match {
[error] ^
[error] /home/suredbits/dev/bitcoin-s/core/src/main/scala/org/bitcoins/core/wallet/utxo/InternalAddressTag.scala:84:5: match may not be exhaustive.
[error] It would fail on the following input: (x: org.bitcoins.core.wallet.utxo.AddressTagType forSome x not in (AddressLabelTagType, StorageLocationTagType, org.bitcoins.core.wallet.utxo.UnknownAddressTagType))
[error] tagType match {
[error] ^
[error] 24 errors found
[error] (core / Compile / compileIncremental) Compilation failed
[error] Total time: 51 s, completed Nov 26, 2020, 9:04:56 AM

@Christewart
Copy link
Contributor Author

I tried some of this on https://github.com/christewart/bitcoin-s-core/tree/2021-06-15-unsealed-pat-mat

but it appears there is some discussion on scala forums that this flag is too strict, and i experienced that too

https://contributors.scala-lang.org/t/trouble-with-2-13-4-exhaustivity-checking-being-too-strict/4817/13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant