How to use a constant as a texture in the setter of an export_enum?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sulucnal

I have this code:

@onready var despawn_sprite: Sprite2D = $DespawnSprite

const SMALL_DESPAWN_TEXTURE : CompressedTexture2D = preload("res://assets/graphics/effects/small_despawn.png")
const BIG_DESPAWN_TEXTURE : CompressedTexture2D = preload("res://assets/graphics/effects/big_despawn.png")
const BIG_DESPAWN_HFRAMES : int = 6

@export_enum("small_despawn", "big_despawn") var despawn_animation : String = "small_despawn":
		match value:
				despawn_sprite.texture = SMALL_DESPAWN_TEXTURE
				despawn_sprite.hframes = SMALL_DESPAWN_HFRAMES
				despawn_sprite.texture = BIG_DESPAWN_TEXTURE
				despawn_sprite.hframes = BIG_DESPAWN_HFRAMES

The texture of my despawn_sprite is set to small_despawn.png by default and things work just fine when I run my game with despawn_animation set to “small_despawn” in the editor. However, trying to select the “big_despawn” option crashes my game and gives me this error message:

Invalid set index 'texture' (on base: 'Nil') with value of type 'CompressedTexture2D'.

What am I doing wrong?