atom / language-ruby

Ruby package for Atom
Other
101 stars 144 forks source link

Incorrect highlighting for numbers with decimal point, e, B and D #251

Closed husseinkhaleel closed 5 years ago

husseinkhaleel commented 6 years ago

Prerequisites

Description

With tree-sitter enabled, numbers with a decimal point (1.0) and e (e.g. 1e3) are not highlighted. Also, numbers defined with capital B (binary) and capital D (decimal) are not highlighted correctly, and possibly parsed under a different category. Small letter b and d are highlighted correctly though. These were the numerical representations that were tested, others could also have the same problem. When tree-sitter is disabled, the highlighting is correct/as expected. This is shown in the images below.

Tree-sitter enabled (by default):

screen shot 2018-11-12 at 4 25 38 pm

Tree-sitter disabled:

screen shot 2018-11-12 at 4 25 10 pm

Steps to Reproduce

  1. Create a new .rb file.
  2. Enable tree-sitter (Preferences->Core) (should be enabled by default).
  3. Declare variables and assign values having decimal point, e, B and D. One can copy-paste the following: a = 10 b = 1.0 c = 1e3 d1 = 0xA; d2 = 0XA e1 = 0o7; e2 = 0O7 f1 = 0b01; f2 = 0B01 g1 = 0d10; g2 = 0D10
  4. Notice the missing/incorrect numerical highlighting.
  5. Disable tree-sitter (Preferences->Core)
  6. Notice the correct numerical highlighting.

Expected behavior: All numerical values should be highlighted correctly.

Actual behavior:

Reproduces how often: 100%

Versions

$ atom --version Atom : 1.32.2 Electron: 2.0.9 Chrome : 61.0.3163.100 Node : 8.9.3

$ apm --version apm 2.1.2 npm 6.2.0 node 8.9.3 x64 atom 1.32.2 python 2.7.10 git 2.18.0

MacOS Mojave Version 10.14.1 (18B75)

Additional Information

N/A

Ben3eeE commented 6 years ago

@maxbrunsfeld These seem to parse as syntax error:

image

husseinkhaleel commented 6 years ago

They should be correct syntax. I use ruby 2.4.2, and these lines execute correctly on my PC. Here is ruby language documentation: https://docs.ruby-lang.org/en/2.0.0/syntax/literals_rdoc.html If one looks into the "Numbers" section, it says: "The alphabetic component of the number is not case-sensitive" There are also examples with upper- and lower-case.

husseinkhaleel commented 6 years ago

In the ruby.cson file on this repository, the identification 'pattern' for numeric checks for both upper- and lower-cases, as shown in the image below. screen shot 2018-11-13 at 9 34 26 am