Skip to content

Shadowing variables #265

Open
Open
@DoomTas3r

Description

@DoomTas3r

What Happened

I thought, 'How can delta from every frame be obtained without creating that variable?' I created the variable with the exact name delta and printed the result which was a float. The debugger displays a warning that delta shadows the already-declared variable.

This unlocks a feature, but it can become a problem if the types don't match

image

Generated script:

extends Node2D

var delta: float


func _ready():
    delta = 0

func _process(delta):
    print((delta))


How to Reproduce

  1. Create a variable named delta
  2. Place an every frame block
  3. Attach a log text block to every frame
  4. Attach delta as input to log text
  5. Run the scene

Block Coding Plugin Version

v0.7.1

Godot Engine Version

v4.3

Operating System

No response

Logs or command-line output

W 0:00:02:0492   The local function parameter "delta" is shadowing an already-declared variable at line 3.
  <GDScript Error>SHADOWED_VARIABLE
  <GDScript Source>gdscript://-9223371985063508500.gd:9

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions