godotengine / godotengine/godot

Using constant Typed Dictionary in _export_file in EditorExportPlugin crashes the engine

Open
#100,458 2 comments 0 reactions 0 assignees View on GitHub
bug confirmed crash topic:export topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Does not work in 4.4-dev4, 4.4-dev6

### System information

Godot v4.4.dev6 - Windows 10.0.19045 - Single-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 4050 Laptop GPU (NVIDIA; 32.0.15.6070) - 13th Gen Intel(R) Core(TM) i5-13500HX (20 threads)

### Issue description

Crashes
```gdscript
func _export_file(path: String, type: String, features: PackedStringArray) -> void:
const EXCLUDED_DIRECTORIES: Dictionary[String, PackedStringArray] = {
"testt": [
"res://testfolder",
]
}

for feature: String in features:
if EXCLUDED_DIRECTORIES.has(feature):
for directory: String in EXCLUDED_DIRECTORIES[feature]:
print(path)
# Skip files inside of this directory
if path.begins_with(directory): skip()
```

Does not crash (same as above but var instead of const)
```gdscript
func _export_file(path: String, type: String, features: PackedStringArray) -> void:
var EXCLUDED_DIRECTORIES: Dictionary[String, PackedStringArray] = {
"testt": [
"res://testfolder",
]
}

for feature: String in features:
if EXCLUDED_DIRECTORIES.has(feature):
for directory: String in EXCLUDED_DIRECTORIES[feature]:
print(path)
# Skip files inside of this directory
if path.begins_with(directory): skip()
```

Does not crash
```gdscript
func _export_file(path: String, type: String, features: PackedStringArray) -> void:
const EXCLUDED_DIRECTORIES: Dictionary = {
"testt": [
"res://testfolder",
]
}

for feature: String in features:
if EXCLUDED_DIRECTORIES.has(feature):
for directory: String in EXCLUDED_DIRECTORIES[feature]:
print(path)
# Skip files inside of this directory
if path.begins_with(directory): skip()
```

### Steps to reproduce

Use a Typed dictionary marked with `const` instead of `var` in _export_file of an EditorExportPlugin, then export the project

### Minimal reproduction project (MRP)

[New Compressed (zipped) Folder.zip](https://github.com/user-attachments/files/18145537/New.Compressed.zipped.Folder.zip)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the crash with the provided minimal project, using a typed Dictionary marked const inside EditorExportPlugin._export_file. Compare the const and var cases during project export, then verify that the typed-constant case no longer crashes while the existing untyped-constant and var cases remain functional.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.