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

yaml grammar recognises some integers as strings (or vice versa?) #39

Open
Tracked by #1
alexr00 opened this issue Feb 23, 2022 · 3 comments
Open
Tracked by #1

yaml grammar recognises some integers as strings (or vice versa?) #39

alexr00 opened this issue Feb 23, 2022 · 3 comments

Comments

@alexr00
Copy link

alexr00 commented Feb 23, 2022

Does this issue occur when all extensions are disabled?: Yes

Version: 1.64.2
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:02:29.527Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.13.0-28-generic snap

OS is Ubuntu 20.04

Description:

Some integers (or strings?) are treated differently even though they look the same to me.

In each comment I've specified what the scope inspector reports the scope as.

This is what it ends up looking like for me:
image

I'd expect them all to be the same; so either they should all be integers or they should all be unquoted strings.

Test case:

test:
  - test: 01 # constant.numeric.integer.yaml
  - test: 02 # constant.numeric.integer.yaml
  - test: 03 # constant.numeric.integer.yaml
  - test: 04 # constant.numeric.integer.yaml
  - test: 05 # constant.numeric.integer.yaml
  - test: 06 # constant.numeric.integer.yaml
  - test: 07 # constant.numeric.integer.yaml
  - test: 08 # string.unquoted.plain.out.yaml
  - test: 09 # string.unquoted.plain.out.yaml
  - test: 10 # constant.numeric.integer.yaml

Steps to Reproduce:

  1. Create a test file, test.yml with the contents from the test case

Originally from @pedroterzero in microsoft/vscode#143368

@rins-dev
Copy link

I think it's not a mistake. Number starts with 0 is an octal, 08 and 09 are error format number

@pedroterzero
Copy link

I think it's not a mistake. Number starts with 0 is an octal, 08 and 09 are error format number

I am not really sure what you mean by this but it still seems inconsistent to me.

@RedCMD
Copy link

RedCMD commented May 16, 2022

The check for base 10 (decimal) numbers does not allow for leading 0's
[-+]? (?: 0|[1-9][0-9_]*) # (base 10)

| [-+]? (?: 0|[1-9][0-9_]*) # (base 10)

cases 00 - 07 are handled by the base 8 (octal) regex
[-+]? 0 [0-7_]+ # (base 8)
which can handle infinite leading 0's

| [-+]? 0 [0-7_]+ # (base 8)

I'm not sure what numerical values in yaml are valid or not
but at this point IMHO the check for decmial should just be \d+

Vscodes repo: https://github.com/microsoft/vscode/blob/c4e1f19aac0ef025ec208bc5d6500df5e5e36600/extensions/yaml/syntaxes/yaml.tmLanguage.json#L460

Issue moved from: microsoft/vscode-textmate#168

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

No branches or pull requests

4 participants