Skip to content

Improper syntax highlighting and parsing of floats. #3964

@k-sriram

Description

@k-sriram

The parser doesn't correctly identify floats which end with the dot.

Environment data

  • VS Code version: 1.30.1
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • OS and version: Linux Manjaro
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A

Expected behaviour

An integer followed by a dot in python represents a float. Hence, 20. should be parsed as a float.

vsc_py_bug_floatsynhilit_expected

Actual behaviour

However, I think this is parsed as the attribute access of an int. It even suggests a list of logical operators for me when I press the dot (which is the actual annoying part).

vsc_py_bug_floatsynhilit_actual

Also, Python doesn't allow you directly access the members of an int by using the dot-syntax after a number.

>>> 20.real
  File "<stdin>", line1
    20.real
          ^
SyntaxError: invalid syntax

Steps to reproduce:

Type a number followed by a dot. Such as 20.. Look at the syntax highlighting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions