Skip to content

Add enum example in documentation and a test for 'case class cannot extend enum' #5014

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 3 commits into from
Aug 25, 2018

Conversation

skvithalani
Copy link
Contributor

I tried to fix #5008 by referring the comment of @Blaisorblade here but am struggling a bit. I happen to play around Typer, Checking and RefChecks to be specific but no luck.

So, this pull request just captures the missing test of 'case class cannot extend enums' and an example addition in enum documentation.

Also, is it possible that I can fix the bug, if so, I would be happy to contribute.

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! ☀️

@skvithalani skvithalani changed the title #5008: Add enum example in documentation and a test for 'case class cannot extend enum' Add enum example in documentation and a test for 'case class cannot extend enum' Aug 25, 2018
Copy link
Contributor

@Blaisorblade Blaisorblade left a comment

Choose a reason for hiding this comment

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

Thanks for the attempt! But we can't merge test cases that fail (see comments).

Sorry if my vague comment mislead you — I certainly did not mean "this is a good issue for novices" — we use the exp:novice or help wanted labels for that.

https://github.com/lampepfl/dotty/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22+
https://github.com/lampepfl/dotty/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22

checkMessagesAfter(RefChecks.name) {
"""
| enum Foo {}
| case class Bar() extends Foo
Copy link
Contributor

Choose a reason for hiding this comment

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

No space after the | — this means code indented by one space.

"""
| enum Foo {}
| enum Bar extends Foo {}
""".stripMargin
Copy link
Contributor

Choose a reason for hiding this comment

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

The best we can do there is place it where it isn't run, tho we usually keep those as issues. Writing good testcases is part of fixing an issue properly anyway.

To observe the failure, you can put the following in tests/neg/i5008.scala, where the // error marker (the space matters!) signals an expected error.

enum Foo {}
enum Bar extends Foo {} // error

By our conventions, we can at best merge that in tests/pending/neg/i5008.scala, not sure what others think.

@skvithalani
Copy link
Contributor Author

I tried to sign CLA and authorized dotty-bot to access my github but the process does not go through till the end and I get the error Invalid login at http://dotty-ci.epfl.ch/. I am assuming since I have already authorized the access, I don't have any more actions to do in terms of CLA. But the status shows CLA not signed. Am I missing something ?

@Blaisorblade Blaisorblade dismissed their stale review August 25, 2018 14:23

Addressed

@Blaisorblade
Copy link
Contributor

Hm, the CLA is indeed not signed yet (https://www.lightbend.com/contribute/cla/scala/check/skvithalani).

Can you sign the Scala CLA from https://www.lightbend.com/contribute/cla/scala/sign? If you get to http://dotty-ci.epfl.ch you're trying to login to control our CI (which only committers can).

@skvithalani
Copy link
Contributor Author

Thanks. I signed it.

Copy link
Contributor

@Blaisorblade Blaisorblade left a comment

Choose a reason for hiding this comment

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

LGTM, and CLA signed.

implicit val ctx: Context = ictx
assertMessageCount(1, messages)
val errorMsg = messages.head
assertEquals("normal case class Bar in package <empty> cannot extend an enum", errorMsg.msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW: we usually don't test strings but that's the correct thing *as long as we don't switch to error messages here (#1589). @skvithalani are you interested in doing that in a followup? Accepting this meanwhile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure . I will take that up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Beyond the pre-labeled issues, ones in parser/desugar tend to be more approachable.

@Blaisorblade
Copy link
Contributor

Related: follow-ups in #5051.

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 enum extending enum
3 participants