godot-console
godot-console copied to clipboard
Error when single or double quote after string
I get the error Invalid operands 'String' and 'Nil' in operator '+'.
when I try writing, for example, somestring'
or even just ''
in the console. It doesn't happen for a singular standalone single/double quote '
. It also doesn't give an error for 3+ quotes '''
.
It's also worth noting that if there is more than one quote after the string ex. hello''
the console will say Command `ello'` not found.
culling the first char in the string, which may or may not be related.
Could you please write your test cases in form:
Input:
Output:
Expected output:
Comment:
Comment might be optional, but generally it is good to have everything described.
Yeah no problem
ID: 1
Input: '
Output: Command `'` not found.
Expected output: Command `'` not found.
Comment: Working as intended
ID: 2
Input: ''
Output: Invalid operands 'String' and 'Nil' in operator '+'.
Expected output: Command `''` not found.
Comment: Output is error shown in debugger
ID: 3
Input: '''
Output: Command `'` not found.
Expected output: Command `'''` not found.
Comment: Strange that this doesn't cause an error
ID: 4
Input: ''''
Output: Command `'` not found.
Expected output: Command `''''` not found.
Comment: Same as above
ID: 5
Input: asdf
Output: Command `asdf` not found.
Expected output: Command `asdf` not found.
Comment: Working as intended
ID: 6
Input: asdf'
Output: Invalid operands 'String' and 'Nil' in operator '+'.
Expected output: Command `asdf'` not found.
Comment: Output is error shown in debugger
ID: 7
Input: asdf''
Output: Command `sdf'` not found.
Expected output: Command `asdf''` not found.
Comment: For whatever reason the `a` in `asdf''` is culled
ID: 8
Input: hello''
Output: Command `ello'` not found.
Expected output: Command `hello''` not found.
Comment: Same as above but for `h`
Above results are the same with "
, just replace all instances of '
with "
Testing other symbols:
ID: 9
Input: asdf;
Output: Command `asdf` not found.
Expected output: Command `asdf;` not found.
Comment: For whatever reason the `;` in `asdf;` is culled
Rest of common symbols:
ID: 10
Input: !
Output: Command `!` not found.
Expected output: Command `!` not found.
Comment: Working as intended
ID: 11
Input: asdf!
Output: Command `asdf!` not found.
Expected output: Command `asdf!` not found.
Comment: Working as intended
Above results are the same with @#$%^&*()-_=+[{]}\|:<,>.?/`~
, just replace all instances of !
with @#$%^&*()-_=+[{]}\|:<,>.?/`~
individually
Number 9 is definitely not an error. Reason is I'm trying to build a posix-like shell.
And ;
is used to separate commands unconditionally. a; b
will run command a then b.
I'll have a look at other cases later when I get to pc.
I'm working on this in a separate branch https://github.com/quentincaffeino/godot-console/tree/fix/command-parsing-79
NOTE: Current implementation of command parser is still the initial one I wrote thinking 'just works (tm)', but with time as I've kept expanding it functionality it became very cluttered and not very pleasant to work with. I plan to completely rewrite it.
I fixed: 2 and 4, both should produce no output as you've basically asked to run an command with empty name. I will merge those fixes shortly and post an update to godotengine asset library.
Now onto what wasn't fixed:
- Currently I don't really want to fix 1, 3 and 6. All of those require an ability to parse multi-line input which would be very hacky with current command parser implementation. Could you elaborate on your use case and why do you need something like
asdf'
? - With 7 and 8 it would also make current parser even harder to work with. Basically
hello
,hello''
,hel'lo'
,hel''lo
andh'el'lo
all mean the same command, except some have enclosed specific parts in strings but in the end all those equals tohello
.
I apologize for not being clear with my reasoning in the initial issue post, I got caught up in the test cases and neglected to mention why. The initial reason I came across this issue was because I slipped and hit '
then the enter key given how close the two keys are on the keyboard and it resulted in a game crash because of the Invalid operands 'String' and 'Nil' in operator '+'.
error which I thought might be an issue if someone else slips. The other cases aren't really critical, but I found them while testing, so I thought they were worth mentioning.
I don't need these strange cases to work, just not crash the game which it looks like the branch fixes, so thank you for that.
It should no longer crash. Thanks for reporting. Other cases are not strange, just very rarely used. I plan to implement them.