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

GDScript 2.0: "Trying to return a typed array with an array of a different type" #60218

Closed
1xch opened this issue Apr 13, 2022 · 2 comments · Fixed by #63325
Closed

GDScript 2.0: "Trying to return a typed array with an array of a different type" #60218

1xch opened this issue Apr 13, 2022 · 2 comments · Fixed by #63325

Comments

@1xch
Copy link

1xch commented Apr 13, 2022

Godot version

4.0.alpha6.official.e4f0fc50f

System information

Linux Ubuntu 20.04

Issue description

Project launched with F5 stops running with breakpoint error:

trying to return a typed array with an array of a diffent type.'

Steps to reproduce

In short for illustration purposes here, this function:

func build(s:Session, c:ConfigFile):
	set_session(s)
	build_arrays(c, _build_test())
	print("BUILD_TEST")

func _build_test() -> Array[Array]:
	return [
		["test", ["test-unmodifiable"], "test", Operator.SYNC],
		["test", ["test-unsyncable"], "test", Operator.READ|Operator.WRITE],
		["test", ["test-string", "test-stringmulti"], "test", Operator.caching_full],
		["test", ["test-bool", "test-boolmulti"], "test", Operator.caching_full],
		["test", ["test-int", "test-intmulti"], "test", Operator.caching_full],
		["test", ["test-float", "test-floatmulti"], "test", Operator.caching_full],
		["test", ["test-vec", "test-vecmulti"], "test", Operator.caching_full],
		["test", ["test-tooltip"], "test", Operator.caching_full],
		["test", ["aaaa", "bbbb", "cccc", "xxxx"],  "test", Operator.caching_full],
	]

goes through the below funcs:

static func build_arrays(c:ConfigFile, d:Array[Array]) -> Array[CNF]:
	var accum:Array[CNF]
	for v in d:
		accum = build_array(c, v, accum)
	return accum

static func build_array(c:ConfigFile, d:Array, accum:Array[CNF]) -> Array[CNF]:
	var get_section = d[0] as String
	var keys = d[1] as Array[String]
	var put_section = d[2] as String
	var flagged = d[3] as int
	return build_keys(keys, c, get_section, put_section, flagged, accum)

static func build_keys(
	keys, # :Array[String],
	c:ConfigFile,
	get_section:String,
	put_section:String,
	flagged:int,
	accum:Array[CNF]) -> Array[CNF]:
	for k in keys:
		var nc = build_cnf(
				c,
				get_section,
				put_section,
				k,
				flagged)
		accum.append(nc)
	return accum  # !!!!!!!!!! ERROR IS HERE in editor 

static func build_cnf(c:ConfigFile, gs:String, ps:String, k:String, cf:int) -> CNF:
	var cnf_val = c.get_value(gs, k, null)
	var pad_val = c.get_value("pad", k, {})
	return CNF.new([gs, k], [ps, k], cnf_val, cf, pad_val)

editor breakpoint error occurs at the return of build_keys with the cooccuring terminal output is:

ERROR: Assignment of arrays of incompatible types.
   at: _assign (core/variant/array.cpp:221)

The accumulator is going in as Array[CNF] and coming out as Array[CNF].

Minimal reproduction project

No response

@Calinou Calinou added this to the 4.0 milestone Apr 13, 2022
@Calinou Calinou changed the title trying to return a typed array with an array of a diffent type GDScript 2.0: "Trying to return a typed array with an array of a differnt type" Apr 13, 2022
@1xch 1xch changed the title GDScript 2.0: "Trying to return a typed array with an array of a differnt type" GDScript 2.0: "Trying to return a typed array with an array of a different type" Apr 13, 2022
@1xch
Copy link
Author

1xch commented Apr 14, 2022

Likely duplicate or relative of #59879, #59721, #59485

Removal of typed arrays allows processing to continue.

@NoodleSushi
Copy link

NoodleSushi commented May 6, 2022

Encountered this issue in 4.0.alpha6
I made a Array[BaseTag] variable catch a function that returns Array[BaseTag], yet the error occurs. It works when I made the function return an untyped Array.
image
image

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

Successfully merging a pull request may close this issue.

3 participants