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

Script editor incorrectly placing @warning_ignore when clicikng [Ignore] link on multi-line expression #80174

Open
Tracked by #40488
JSchrepp opened this issue Aug 2, 2023 · 1 comment

Comments

@JSchrepp
Copy link

JSchrepp commented Aug 2, 2023

Godot version

4.0.3

System information

Windows 11

Issue description

The editor gives a button/link [Ignore] preceding warnings to insert a suppression annotation for the developer on the line above. However, this insertion doesn't take code syntax into account and will blindly insert the annotation above the detected line, only giving it correct indentation. Multi-line expressions are unable to handle this, and the entire area of code lights up with errors. Code sample provided in reproduction steps. Manually moving the warning above the full expression successfully suppresses the warning.

I expect one of two things:

  1. The editor insert the suppression mechanism in a safe place
  2. The suppression mechanism not interrupt expressions

I imagine 1 is the easiest solution to take, as annotations are code and they need to be placed in valid locations according to their function. But I'd like to take a moment to state that something like 2 would be amazing. Many languages implement arbitrary warning suppression via directives. E.g. a lot of the C family of languages uses #pragma to instruct the compiler to hold off on specific warnings in the file until otherwise stated. I don't know how possible that is for an interpreted language vs a compiled one, it's really not my domain, but it would be amazing if it were possible.

Side-note, I found myself trying to suppress this warning after running into #74397 on a nameless script

Steps to reproduce

Sample code to reproduce:

func instance_func():
    @warning_ignore("static_called_on_instance")
    print([
        0,
        static_func() # fails
    ])
    print([
        static_func(), # fails
        0
    ])
    print([0, static_func()]) # works
    print([static_func(), # works
        0
    ])
    return 0 + \
        static_func() # fails

static func static_func() -> int:
    return 0

Paste this in a script and click the [Ignore] text in the warnings list beneath the text editor
image

Minimal reproduction project

N/A. Reproduction just takes the given snippet in a fresh project.

@dalexeev
Copy link
Member

dalexeev commented Aug 2, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants