Skip to content

Incorrect array element type error for arg when method is called on non-typed class property with non-typed arg #86963

Closed
@moritztim

Description

Tested versions

  • Reproducible in v4.2.1.stable.arch_linux

System information

Arch Linux

Issue description

A class has a method (some_method) that accepts an Array[String].
some_method is called with an array containing a constant.
If the class instance is stored as a non-typed property (of another class) and the method is called with an identical array, the engine raises a type error.

Steps to reproduce

Code:

extends Object

var prop
var typed_prop: C

class C:
	func trouble_maker(_a: Array[String]): return

func bug():
	var local = C.new()
	local.trouble_maker([""])
	print("local works")
	
	typed_prop = C.new()
	typed_prop.trouble_maker([""])
	print("typed_prop works")

	var arg: Array[String] = [""]
	prop = C.new()
	prop.trouble_maker(arg)
	print("prop with typed arg works")

	prop = C.new()
	prop.trouble_maker([""])
	print("prop with expression arg works")

Output:

local works
typed_prop works
prop with typed arg works

Error:

Invalid type in function 'trouble_maker' in base 'RefCounted (C)'. The array of argument 1 (Array) does not have the same element type as the expected type array argument.

Minimal reproduction project (MRP)

mrp.zip

Minimal reproduction script

extends Object
var prop
class C: func m(_a: Array[String]): return
func f():
 prop = C.new()
 prop.m([""])

to get the error, run f()

Activity

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

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