Skip to content

Commit 4352a4a

Browse files
Enno Runnefelixmulder
Enno Runne
authored andcommitted
Incorporated comments from @felixmulder
1 parent e668fd7 commit 4352a4a

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,13 @@ object Parsers {
404404

405405
var opStack: List[OpInfo] = Nil
406406

407-
def checkAssoc(offset: Int, op: Name, leftAssoc: Boolean, op2: Name) =
408-
if (isLeftAssoc(op) != leftAssoc)
409-
syntaxError(MixedLeftAndRightAssociativeOps(op, op2, leftAssoc), offset)
407+
def checkAssoc(offset: Token, op1: Name, op2: Name, op2LeftAssoc: Boolean): Unit =
408+
if (isLeftAssoc(op1) != op2LeftAssoc)
409+
syntaxError(MixedLeftAndRightAssociativeOps(op1, op2, op2LeftAssoc), offset)
410410

411411
def reduceStack(base: List[OpInfo], top: Tree, prec: Int, leftAssoc: Boolean, op2: Name): Tree = {
412412
if (opStack != base && precedence(opStack.head.operator.name) == prec)
413-
checkAssoc(opStack.head.offset, opStack.head.operator.name, leftAssoc, op2)
413+
checkAssoc(opStack.head.offset, opStack.head.operator.name, op2, leftAssoc)
414414
def recur(top: Tree): Tree = {
415415
if (opStack == base) top
416416
else {

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,20 +1098,21 @@ object messages {
10981098
val kind = "Syntax"
10991099
val op1Asso = if (op2LeftAssoc) "which is right-associative" else "which is left-associative"
11001100
val op2Asso = if (op2LeftAssoc) "which is left-associative" else "which is right-associative"
1101-
val msg = s"${hl"`${op1}`"} (${op1Asso}) and ${hl"`${op2}`"} ($op2Asso) have same precedence and may not be mixed"
1101+
val msg = s"`${op1}` (${op1Asso}) and `${op2}` ($op2Asso) have same precedence and may not be mixed"
11021102
val explanation =
1103-
s"""|The operators ${hl"${op1}"} and ${hl"${op2}"} are used as infix operators in the same expression,
1103+
s"""|The operators ${op1} and ${op2} are used as infix operators in the same expression,
11041104
|but they bind to different sides:
1105-
|${hl"${op1}"} is applied to the operand to its ${if (op2LeftAssoc) "right" else "left"}
1106-
|${hl"${op2}"} is applied to the operand to its ${if (op2LeftAssoc) "left" else "right"}
1105+
|${op1} is applied to the operand to its ${if (op2LeftAssoc) "right" else "left"}
1106+
|${op2} is applied to the operand to its ${if (op2LeftAssoc) "left" else "right"}
11071107
|As both have the same precedence the compiler can't decide which to apply first.
11081108
|
11091109
|You may use parenthesis to make the application order explicit,
1110-
|or use method application syntax ${hl"`operand1.${op1}(operand2)`"}.
1110+
|or use method application syntax `operand1.${op1}(operand2)`.
11111111
|
11121112
|Operators ending in a colon `:` are right-associative. All other operators are left-associative.
11131113
|
1114-
|Infix operator precedence is determined by the operator's first character:
1114+
|Infix operator precedence is determined by the operator's first character. Characters are listed
1115+
|below in increasing order of precedence, with characters on the same line having the same precedence.
11151116
| (all letters)
11161117
| |
11171118
| ^
@@ -1122,7 +1123,7 @@ object messages {
11221123
| + -
11231124
| * / %
11241125
| (all other special characters)
1125-
|Operators starting with a letter have lowest precedence, followed by operators starting with `|', etc.
1126+
|Operators starting with a letter have lowest precedence, followed by operators starting with `|`, etc.
11261127
|""".stripMargin
11271128
}
11281129

0 commit comments

Comments
 (0)