What's causing the error "Expected closing ")" after call arguments" in this script?

Godot Version

4.1.3-stable

Question

I have what I thought should be a simple line of code, but I’m getting the error “Expected closing “)” after call arguments” on it. Here’s the code:

	var lambda_filter = func(tile_type):
		return isAdjacencyValid(tile_options : Array[TileType], tile_type, adjacent_tile)

The error is after the first ‘T’ character in [TileType]

Here’s the code around it, if it’s needed:

func update_from_adjacent(tile_map : Array[Array], tile_options : Array[TileType], adjacent_tile: Tile):
		var update_propagation_required = false
		# update the tile data here
		print("Updating Tile: " + str(position) + " from: " + str(adjacent_tile.position))
		var starting_length = tile_types.size()
		var lambda_filter = func(tile_type):
			return isAdjacencyValid(tile_options : Array[TileType], tile_type, adjacent_tile)
			
		tile_types.filter(lambda_filter)
		if(tile_types.size() != starting_length):
			update_propagation_required = true
		
		# propagate updates to bordering tiles
		if(update_propagation_required):
			update_adjacent_tiles(tile_map)
		
		# if there is only one more possible type, the tile is fully collapsed, so it is marked as collapsed
		if(tile_types.size() == 1):
			collapsed = true

What’s causing this error, and how do I fix it? I’ve used the identical syntax in many other functions in this project, and it hasn’t had this error there. The only difference I can think of is that this is a lambda function, but I don’t know why that would cause this with my current knowledge.

1 Like

The problem is that you are giving a type in the call. You can only give type hints when defining a function. Not when calling one.

So you need to change the call to:

isAdjacencyValid(tile_options, tile_type, adjacent_tile)
1 Like

Oh, I feel a bit silly… I knew that, but I just forgot that I wasn’t defining it anymore. Thank you :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.