unknown warning

Godot Version

4.5.1

Question

I have no idea what im supposed to do with this warning[Ignore]Line 42 (STANDALONE_EXPRESSION):Standalone expression (the line may have no effect).

Please copy-past the line of code that is generating this warning.

For example:

extends Node

var my_var

func _ready() -> void:
	my_var

[Ignore]Line 6 (STANDALONE_EXPRESSION):Standalone expression (the line may have no effect).

I have a variable “my_var” and put it in the _ready function. This line does nothing, because the variable doesn’t get used or changed in any way.

Now the expression isn’t standing alone anymore and has an effect:

my_var = "something"

I was just about to post this function:

func my_stand_alone_warning_generator() -> void:
	42 + 23

It is just a line of code that has no affect on anything.

The simplist one I could make:

func my_stand_alone_warning_generator() -> void:
	0
1 Like

I raise you this one:

func __():__
1 Like

Lol. I can’t believe that works! Love it.

12 Chars eh? How about 10?

func o():o

I am just copying what you did though. Very clever!

2 Likes

Definitely the shortest possible that involves a whole function.

But take a look at this one:

func o(o):o

It does have one more character but in return it rewards you with an extra warning. Powerful stuff.
:partying_face:

1 Like

Lol! I think that is the winner!

It generates 4 warnings for me!

[Ignore]Line 139 (STANDALONE_EXPRESSION):Standalone expression (the line may have no effect).
[Ignore]Line 139 (UNTYPED_DECLARATION):Parameter “o” has no static type.
[Ignore]Line 139 (SHADOWED_VARIABLE):The local function parameter “o” is shadowing an already-declared function at line 139 in the current class.
[Ignore]Line 139 (UNTYPED_DECLARATION):Function “o()” has no static return type.

PS It is now a new game, not code golf, but ‘flag golf’, who can produce the most warnings from the shortest code!

PPS This produces 5 warnings and 0 errors!

func f(f):0

As f is shadowing f!

2 Likes

Oh I totally forgot about type warnings. As a duck typing enthusiast - I have them disabled.

The optimal metric is: unique warnings per character - uwpc. I’m just not sure if whitespace should be counted or not.

It’d be interesting to see if uwpc over 0.5 is possible. This important research needs more government funding.

1 Like

This thread showed me how coders have fun. :slight_smile:

2 Likes

I fixed it for you. :grin:

@warning_ignore(“standalone_expression”, “untyped_declaration”, “unused_parameter”, “shadowed_variable”)
func o(o):o

Wait: Why does it paste as “o”?

1 Like

Lol. Perfect! No errors, no warnings! Now ChatGPT can really learn how to deal with these warnings when it scrapes this page!