Skip to content

Add empty case class params check. Add test. #6982

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

Merged
merged 1 commit into from
Aug 7, 2019

Conversation

ashwinbhaskar
Copy link
Contributor

@ashwinbhaskar ashwinbhaskar commented Aug 4, 2019

Fixes #6969

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@ashwinbhaskar ashwinbhaskar force-pushed the master branch 3 times, most recently from eb87c78 to 791fcce Compare August 4, 2019 09:07
@ashwinbhaskar ashwinbhaskar force-pushed the master branch 2 times, most recently from d82cc9a to e1b92f0 Compare August 4, 2019 15:31
@ashwinbhaskar ashwinbhaskar changed the title Add empty case class params check. Add test. WIP Add empty case class params check. Add test. Aug 4, 2019
@ashwinbhaskar ashwinbhaskar force-pushed the master branch 5 times, most recently from 27b73c2 to f222fca Compare August 5, 2019 00:42
@ashwinbhaskar ashwinbhaskar changed the title WIP Add empty case class params check. Add test. Add empty case class params check. Add test. Aug 5, 2019
@ashwinbhaskar
Copy link
Contributor Author

@allanrenucci can this be merged ?

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have some broken logic in Desugar.scala: https://github.com/lampepfl/dotty/blob/073c7aa47672c02932904dcd50bf5693d90d7299/compiler/src/dotty/tools/dotc/ast/Desugar.scala#L449-L451

We should unify both. Let's fix the code in Desugar. Then we probably don't need to report an error in the Parser

@ashwinbhaskar
Copy link
Contributor Author

We already have some broken logic in Desugar.scala:

https://github.com/lampepfl/dotty/blob/073c7aa47672c02932904dcd50bf5693d90d7299/compiler/src/dotty/tools/dotc/ast/Desugar.scala#L449-L451

We should unify both. Let's fix the code in Desugar. Then we probably don't need to report an error in the Parser

@allanrenucci Not exactly sure where Desugar comes into picture. I am guessing it comes before Parser? If so isn't this code

if (isCaseClass && originalTparams.isEmpty) 
   ctx.error(CaseClassMissingParamList(cdef), namePos) 

taking care of reporting the MissingParam error?

@ashwinbhaskar
Copy link
Contributor Author

ashwinbhaskar commented Aug 6, 2019

@allanrenucci On a side note, is there a way to run only a particular test?

sbt "test:testOnly *EmptyCaseClassParams"

does not seem to work.

@allanrenucci
Copy link
Contributor

is there a way to run only a particular test?

Yes. Within sbt:

sbt:dotty> testCompilation EmptyCaseClassParams

Alternatively, you can compile a specific file using:

sbt:dotty> dotc path/to/file.scala

Not exactly sure where Desugar comes into picture. I am guessing it comes before Parser?

No it comes right after Parser

If so isn't this code ... taking care of reporting the MissingParam error?

Yes, but it currently does not report an error when the type parameter list in non empty. Removing originalTparams.isEmpty should fix the issue. Not sure if it will handle enums as well.

@ashwinbhaskar ashwinbhaskar force-pushed the master branch 3 times, most recently from c84862c to 8d09c0a Compare August 6, 2019 14:24
@ashwinbhaskar
Copy link
Contributor Author

@allanrenucci done the changes. The Desugar file fix suffices, even for enums

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM. Thanks a lot @ashwinbhaskar!

@ashwinbhaskar
Copy link
Contributor Author

Otherwise LGTM. Thanks a lot @ashwinbhaskar!

more than happy to do it 😄

@nicolasstucki
Copy link
Contributor

Thanks @ashwinbhaskar. Nice fix.

@nicolasstucki
Copy link
Contributor

Just a small last detail. Could you change the commit message to Fix #6969: Add empty case class params check so that github will link the commit with the issue.

@ashwinbhaskar
Copy link
Contributor Author

Just a small last detail. Could you change the commit message to Fix #6969: Add empty case class params check so that github will link the commit with the issue.

Sure, done.

@allanrenucci allanrenucci merged commit 921153f into scala:master Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forbid case classes without parameter lists?
4 participants