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

Commenting multi-line code may lead to unnecessary warning #33687

Closed
Tracked by #40488
njourdane opened this issue Nov 17, 2019 · 5 comments
Closed
Tracked by #40488

Commenting multi-line code may lead to unnecessary warning #33687

njourdane opened this issue Nov 17, 2019 · 5 comments

Comments

@njourdane
Copy link

njourdane commented Nov 17, 2019

Godot version:

3.1.1 stable

OS/device including version:

Kubuntu

Issue description:

Commenting multi-line code may lead to unnecessary warning.

Steps to reproduce:

Type some code with multil-ine code:

func new_issue():
    if 'Roses' == 'blue' \
    and 'Violets' == 'blue' \
    and 'Sugar' == 'sweet':
        print('And so are you.')

image

Then comment some line(s) inside:

func new_issue():
    if 'Roses' == 'blue' \
#    and 'Violets' == 'blue' \
    and 'Sugar' == 'sweet':
        print('And so are you.')

image

As you can see, this produces a red warning, even if the code without this line is syntactically correct.

@Calinou
Copy link
Member

Calinou commented Nov 17, 2019

Using parentheses to wrap a statement over multiple lines should avoid this issue, while generally being easier to refactor:

func new_issue():
    if (
        'Roses' == 'blue'
#        and 'Violets' == 'blue'
        and 'Sugar' == 'sweet'
    ):
        print('And so are you.')

It'd still be good to fix this issue if possible.

@name-here
Copy link

Fixing it would also allow you to avoid the frown at the end of your if statement.

@fsy98
Copy link
Contributor

fsy98 commented Nov 24, 2019

Actually, this problem is because colon missing at the end of if - or func-line, so the next line will confused and show the mistake in the degugger. For C and C++ the syntax you give is ok, but for godot make some problem like python.

@ThakeeNathees
Copy link
Contributor

ThakeeNathees commented Mar 10, 2020

it's not a bug, its an expected behavior the symbol "\" means just ignore the next new line character

in python

if True and True\
## comment
    or False:
    print("test")

## output error
 File "test.py", line 3
    ## comment
            ^
SyntaxError: invalid syntax

in c++

#define TEST                       \
	if (true){                   \
		// comment
		print_line("test");   \
	}
// this is also an invalid define macro

and also having even an extra white space after the "\" character is invalid
if you write something like this

if 'Roses' == 'blue' \
#    and 'Violets' == 'blue' \
    and 'Sugar' == 'sweet':
        print('And so are you.')

the gdscript tokenizer sees it like this

if 'Roses' == 'blue' #    and 'Violets' == 'blue'      and 'Sugar' == 'sweet':
        print('And so are you.')

@KoBeWi
Copy link
Member

KoBeWi commented Dec 17, 2020

Closing as per above comment.

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

6 participants