20milliliter / command-terminal

An addon for Godot 4 that manages a developer-created Command Line, with the goal of providing flexible commands, with direct but safe interaction with business logic, through readable command declarations.
MIT License
12 stars 1 forks source link

Building branch with only one branch creates dirty exception #4

Open 20milliliter opened 2 weeks ago

20milliliter commented 2 weeks ago

The following code:

CommandServer.register_command(
    CommandBuilder.new()
        .Literal("foo")
        .Branch()
            .Literal("bar")
            .Callback(print, ["baz"])
        .EndBranch()
    .Build()
)

produces dirty exception: Trying to assign a value of type "Nil" to a variable of type "Array[ArgumentNode]". @ CommandBuilder.gd:68

CommandBuilder contains an attempt to catch this error, but,

  1. it doesn't work as is
  2. its condition and assumed error would result in false positives
tkim602 commented 2 weeks ago

Hi, can I give it a try for this issue?

20milliliter commented 2 weeks ago

Sure. Just make sure that regular case (Branch(), NextBranch(), EndBranch()), single case (Branch(), EndBranch()), and invalid case (EndBranch()) all work as expected (no error, no error, error, respectively)

tkim602 commented 2 weeks ago

@20milliliter Hi I tired to try this issue but I figured out that this is kind of beyond my abilities. I do not think I can handle this. Sorry.

20milliliter commented 2 weeks ago

No worries, thank you for at least trying.