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

Fix #1589: Reworks with explanation error:modifiers(s) not allowed for 'item' #2747

Merged
merged 6 commits into from Jun 15, 2017

Conversation

johnregan
Copy link

@johnregan johnregan commented Jun 13, 2017

Parsers-1685 : Sample compilation error

-- [E082] Syntax Error: /home/jr/projects/dotty/tests/neg/validate-parsing.scala:4:7 
4 |  lazy trait T // error: modifier(s) `lazy' not allowed for trait
  |       ^^^^^
  |       modifier(s) `lazy' not allowed for trait

Explanation

You tried to use a modifier that is inapplicable for the type of item under modification

Consider the following example:
sealed def y: Int = 1
In this instance, the modifier 'sealed' is not applicable to the item type 'def' (method)

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 ("Added" instead of "Add")
  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! ☀️

@johnregan johnregan changed the title Applies dotty error message standard - modifier(s) 'modifiers' not al… Fix#1589: modifiers not allowed for trait Jun 13, 2017
@johnregan johnregan changed the title Fix#1589: modifiers not allowed for trait Fix #1589: modifiers not allowed for trait Jun 13, 2017
@johnregan johnregan changed the title Fix #1589: modifiers not allowed for trait Fix #1589: MODIFIERS NOT ALLOWED FOR TRAIT Jun 13, 2017
@johnregan johnregan changed the title Fix #1589: MODIFIERS NOT ALLOWED FOR TRAIT Fix #1589: DOTTY ERROR REWORK - MODIFIERS NOT ALLOWED FOR Jun 13, 2017
@johnregan johnregan changed the title Fix #1589: DOTTY ERROR REWORK - MODIFIERS NOT ALLOWED FOR Fix #1589: Reworks with explanation error:modifiers(s) not allowed for 'item' Jun 13, 2017
@johnregan
Copy link
Author

@felixmulder can you take a look ?

Copy link
Contributor

@felixmulder felixmulder left a comment

Choose a reason for hiding this comment

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

Minor nitpicks, otherwise LGTM! Thanks for contributing! 🎉

@@ -89,8 +89,8 @@
OnlyCaseClassOrCaseObjectAllowedID,
ExpectedClassOrObjectDefID,
AnonymousFunctionMissingParamTypeID,
SuperCallsNotAllowedInlineID
;
Copy link
Contributor

Choose a reason for hiding this comment

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

The idea with having this on a separate line is that we won't get a - diff when adding an ID

|
|Consider the following example:
|$code
|In this instance, the modifier 'sealed' is not applicable to the item type 'def' (method)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also possibly try to identify which flags have been applied to what and make a suggestion. That would be cool 😄

Copy link
Author

Choose a reason for hiding this comment

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

@felixmulder not quite sure how to identify all modifiers for traits,methods,variables. Should this not be handled instead by the next error,
1693 syntaxError(s"illegal modifier combination: ${mods.flags} and $flag")

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I think these two should be harmonized. I.e. the same error message for both. You could make sort: Option[String] to discern between the case _ and the rest of them.

Otherwise this LGTM now :)

Copy link
Author

Choose a reason for hiding this comment

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

Cool, I can take that one next. Can we agree that it will be handled with the 1693 consolidation refactor and get this one through? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure - that's fine by me - assigning you in #1589

@@ -90,7 +90,8 @@
ExpectedClassOrObjectDefID,
AnonymousFunctionMissingParamTypeID,
SuperCallsNotAllowedInlineID,
ModifiersNotAllowedID;
ModifiersNotAllowedID
Copy link
Contributor

Choose a reason for hiding this comment

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

You should leave the trailing , at the end so the next diff wont change this line

  ...
  AnonymousFunctionMissingParamTypeID,
  SuperCallsNotAllowedInlineID,
  ModifiersNotAllowedID,
  ;

Copy link
Author

Choose a reason for hiding this comment

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

ok thanks nicolass

@felixmulder felixmulder merged commit 78c42c7 into scala:master Jun 15, 2017
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.

None yet

4 participants