This repository was archived by the owner on Sep 1, 2020. It is now read-only.
forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 19
Allow primes at the end of identifiers. #29
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
primed-identifiers.scala:4: error: value b' is not a member of object a1 | ||
a1 b'c' // parses as a1 b' c' | ||
^ | ||
primed-identifiers.scala:4: error: not found: value c' | ||
a1 b'c' // parses as a1 b' c' | ||
^ | ||
two errors found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object a1 { | ||
def b(c: Char) = ??? | ||
|
||
a1 b'c' // parses as a1 b' c' | ||
} | ||
|
||
object a2 { | ||
def b'(c: Int) = ??? | ||
def b(c: Char) = ??? | ||
|
||
val c' = 23 | ||
a2 b'c' // parses as a2 b' c' | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
object Test { | ||
val l = List("Identifiers", "with", "primes", "!") | ||
|
||
val l' = l map(_.length) | ||
|
||
val l'' = l zip l' | ||
|
||
val l''' = l''.reverse | ||
|
||
object a1 { | ||
def b(c: Char) = ??? | ||
|
||
a1 b 'c' | ||
} | ||
|
||
object a2 { | ||
def b'(c: Int) = ??? | ||
def b(c: Char) = ??? | ||
|
||
a2 b' 23 | ||
a2 b'23 | ||
|
||
val i = 23 | ||
a2 b'i | ||
|
||
val c' = 23 | ||
a2 b'c' // parses as a2 b' c' | ||
|
||
a2 b 'c' | ||
} | ||
|
||
case object Foo' | ||
case class Bar'(i: Int) | ||
|
||
((): Any) match { | ||
case foo': String => ??? | ||
case Foo' => ??? | ||
case Bar'(foo') => ??? | ||
} | ||
|
||
val (x', y') = (13, 23) | ||
|
||
for (z' <- List(x', y')) x'*2 | ||
|
||
type T' = Int | ||
def foo[U', F'[_]](ft: F'[T'], fu: F'[U']) = (ft, fu) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scalac would parse
a1 b'c'
asa1.b('c')
, while the Typelevel compiler would parse it asa1.b'(c')
. Not sure if this is something permitted under your compatibility guidelines, but you should probably warn this (or require a language import).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a1 b'c'
parsing correctly sort of strikes me as a bug, though? Shouldn't it require a space?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, Iulian! It's also an issue with symbol literals, unsurprisingly.
Regardless of whether it's considered a bug (in Scalac) or not, it's a
difference, so we'll need to put it under a -Z flag.
Given there are likely to be several very subtle parsing differences like
this -- which in all likelihood don't affect anyone that much -- would it
make sense to group them under a single -Z flag?
On 18 September 2014 13:15, Nami-Doc notifications@github.com wrote:
Jon Pretty | @propensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nami-Doc it's not a bug, according to the grammar in the SLS. Generally, space is not required between tokens (that's why you can write
foo(x)
without any space between the 4 tokens).@propensive a -Z flag would work, but why not an
import language.typelevel.syntax
, or something like that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dragos language flags work by using implicits, they're not in scope during the parser (i.e. it hasn't even gotten to typing, yet) - we need to figure out a solution for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've only got my/Martin's suggestion of passing both possible parsings
through to the typer, somehow. But I can't imagine how this could be any
less terrible than it sounds.
On 18 Sep 2014 15:14, "Brian McKenna" notifications@github.com wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm pretty certain that aint gonna happen.
Notice that the name is MutableSettings, though. What if the Parser were to... mutate them? 👿
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, the name MutableSettings was intended as documentation, not as guidance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@puffnfresh spot on about imports... too bad.