godotengine / godotengine/godot-cpp
Passing type-hinted parameter to function causes crash
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
I have 2 classes which both inherit from `Object`: `Board` and `BoardMove`.
In `Board` I have this method: `void Board::do_move(BoardMove *move);` which takes in the `BoardMove` class as a parameter.
If I try to call this method in gdScript like this:
```gdscript
func _ready():
# Create a new chess board from the starting position
var board = Board.from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
# Creates a new board move
var move = BoardMove.make(62, 45)
# Perform the move
board.do_move(move)
```
It works just fine.
Now lets add type hints.
```gdscript
func _ready() -> void:
# Create a new chess board from the starting position
var board: Board = Board.from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
# Creates a new board move
var move: BoardMove = BoardMove.make(62, 45)
# Perform the move
board.do_move(move)
```
It crashes without any error message.
For some reason adding type hinting to the `var move` variable makes the `board.do_move` method crash the game. This might be related #1025.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.