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

[Ruby] Modulo of negative number (e.g. "15%-4") incorrectly highlighted as start of percent string #1166

Open
Nnnes opened this issue Sep 20, 2017 · 1 comment
Labels
C: Syntax on hold Something that can't be done, or done correctly, right now T: bug A bug in an existing language feature

Comments

@Nnnes
Copy link

Nnnes commented Sep 20, 2017

%-string content- # good highlighting; equivalent to "string content"
15 % -4 - 6 == -7 # good highlighting
15"4 " 6==-7      # good highlighting (despite broken syntax)
15%-4 - 6==-7     # bad highlighting; highlighted in the same way as the above line

The highlighting appears incorrectly in GitHub the same way that it does in Sublime Text. A true fix is likely not feasible:

int = 15

def str(arg)
  "string: #{arg}"
end

puts int %-4 #-
puts str %-4 #-

is interpreted the same as

int = 15

def str(arg)
  "string: #{arg}"
end

puts int % -4
puts str("4 #")

so both output

-1
string: 4 #
@FichteFoll
Copy link
Collaborator

FichteFoll commented Sep 21, 2017

Since

puts int %-4 #-
puts str %-4 #-

uses exactly the same syntax, you won't be able to get highlighting with ST's engine that is 100% correct, but it can at least try to guess whether the content of a percent string would consist of only a (negative) number and consider it to be the modulo operator instead.

But why, Ruby, why?

(I confirmed this btw.)

@deathaxe deathaxe added T: bug A bug in an existing language feature on hold Something that can't be done, or done correctly, right now C: Syntax labels Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax on hold Something that can't be done, or done correctly, right now T: bug A bug in an existing language feature
Projects
None yet
Development

No branches or pull requests

3 participants