Skip to content

Assigning any value to LinkedList.front directly results in an error #17

@Xrayez

Description

@Xrayez

Goost and Godot version:
gd3 @ 455ebc0, 3.2.

OS/device including version:
Windows 10.

Issue description:
Attempting to assign any value to LinkedList.front directly results in an error:

'Invalid set index 'front' (on base: 'LinkedList') with value of type 'ListNode'.'

Steps to reproduce:

func test_list_assign_via_front():
	list.push_back("A")
	assert_not_null(list.front)
	assert_eq(list.front.value, "A")

	# FIXME: This doesn't work, throws an error:
	list.front.value = "B"
	assert_eq(list.front.value, "B")

	# But this works:
	var n = list.front
	n.value = "B"
	assert_eq(list.front.value, "B")

	# This also works:
	list.find("A").value = "B"
	assert_eq(list.front.value, "B")

That's really strange because:

  • we never assign any kind of ListNode in the snippet above.
  • the reported base is wrong, should be ListNode.

I've actually stumbled upon this while implementing linked list in #12, but never got to resolve this issue:

func test_list_inside_list_node__via_manual_value_set():
var nodes = populate_test_data(list)
assert_not_null(list.find("Goost"))
var new_list = LinkedList.new()
var new_node = new_list.push_back("Godot")
assert_eq(new_node.value, "Godot")
assert_not_null(list.front)
# This works.
var n = list.front
n.value = new_list
# FIXME: the following doesn't work, throws an error:
# 'Invalid set index 'front' (on base: 'LinkedList') with value of type 'ListNode'.'
# Despite the fact that `new_list` is NOT a `ListNode`,
# and the referenced `front` property is incorrect (the above works).
#
# list.front.value = new_list
assert_eq(list.front.value.front.value, "Godot")

So, I'm not sure if that's caused by a particular implementation in Goost, or this may actually be a GDScript bug in 3.2, because other workarounds work, I don't understand why it wouldn't work in this case.

Minimal reproduction project:
list_assign_front.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions