Skip to content

Change 'mixed left- and right-associative operators' to Message #1985

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

Closed
wants to merge 14 commits into from

Conversation

ennru
Copy link
Contributor

@ennru ennru commented Feb 15, 2017

@felixmulder
This becomes a habit. Next syntax error to the Message scheme, with more explanation from the language specs.
Not really sure if in.name is the correct name of the second operator in second part ofinfixOps.

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.

Otherwise LGTM 👍

| :
| + -
| * / %
| (all other special characters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, just reading this with my noob-glasses on, I'd think that letters had the greatest precedence. Then I'd see the sentence on the next line...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I added a bit more from the language spec.
Would be an idea to provide links to the spec or Stack overflow...

val op2Asso = if (op2LeftAssoc) "which is left-associative" else "which is right-associative"
val msg = s"${hl"`${op1}`"} (${op1Asso}) and ${hl"`${op2}`"} ($op2Asso) have same precedence and may not be mixed"
val explanation =
s"""|The operators ${hl"${op1}"} and ${hl"${op2}"} are used as infix operators in the same expression,
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use the hl interpolator? You still have to interpolate values for them to be highlighted. If there is some interpolated part of the message that gets highlighted incorrectly, you can wrap it in NoColor(..) or some other "color" that you find more suitable.

Anyway, choose the lesser evil - if hl requires more boilerplate, then of course s is preferable.

@@ -404,14 +404,13 @@ object Parsers {

var opStack: List[OpInfo] = Nil

def checkAssoc(offset: Int, op: Name, leftAssoc: Boolean) =
def checkAssoc(offset: Int, op: Name, leftAssoc: Boolean, op2: Name) =
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming you want to avoid a larger diff, but it looks weird that op2 is at the end. If you want to refactor that - put it in a second commit and we'll merge both of them unsquished.

nicolasstucki and others added 13 commits February 16, 2017 21:11
* Add `isSyntheticFunction` checks for synthetic functions such as FuntionN
for N > 22 and ImplicitFunctionN for N >= 0.
* Add `erasedFunctionClass` to get the erased verion of synthetic functions.
* Change the semantics of `isFunctionClass` to return  true if it is any kind of
FunctionN or ImplicitFunctionN.
This was already be done in TreeTraverser but should also be done in
TreeMap and TreeAccumulator for ctx.error(..., tree.pos) to not use
completely incorrect positions inside inlined trees.
We cannot assume that the untyped rhs of the bind is a `Typed` tree,
with extractors it might be an `Apply` node, and in general it might
also be a `Parens` node.
Previously we never used the `pos` argument of `checkNoPrivateLeaks` and
instead used `sym.pos`, this makes a difference for calls to
`avoidPrivateLeaks` coming from `TreeUnpickler` where we should use
`tree.pos` instead.
This is necessary if we ever want to get rid of our dependency on scala-compiler
@felixmulder
Copy link
Contributor

felixmulder commented Feb 20, 2017

@ennru: Github seems to struggle with your rebased PRs, it might be due to the email you're signing commits with not being associated with your Github account.

I rebased your branch and merged it as #2007 instead, hope that's ok with you!

@ennru
Copy link
Contributor Author

ennru commented Feb 20, 2017

@felixmulder_ Thank you for pointing out my wrong git user as the problem, I was wondering what was going on.
Sorry for the extra work this resulted in for you.

@felixmulder
Copy link
Contributor

felixmulder commented Feb 20, 2017 via email

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.

5 participants