Operating system or device, Godot version, GPU Model and driver (if graphics related):
Godot 2.1.3 stable official, Antergos Linux x86_64, 4.12.8-2-ARCH
Issue description:
I added an inbuilt script to a viewport node and copied over the size and stretch override code example from Godot's docs inside the _ready()
It would be copied over unindented as so:
extends Viewport
func _ready():
viewport.set_size_override(w,h) #custom size for 2D
viewport.set_size_override_stretch(true/false) #enable stretch for custom size
And then, if I indented both lines of code as such:
extends Viewport
func _ready():
viewport.set_size_override(w,h) #custom size for 2D
viewport.set_size_override_stretch(true/false) #enable stretch for custom size
Godot will crash. This does not just apply to the viewport node, but to any node, it seems, as I tried it out on a panel node as well and it led to a crash.
P.S: For some reason, Godot's editor didn't allow code to be copied from it :/
Steps to reproduce:
Create a node. Attach a script. Copy/paste the aforementioned code from the Godot docs into the _ready() function and, sometimes without saving, Godot will crash.
THIS DOES NOT HAPPEN IF THE CODE IS WRITTEN BY HAND. (Edit: ok nvm this bit - it's because when writing by hand I didn't include the true/false division argument to the size_override_stretch function...)
Well, when I look more closely... it happens because after I fix the indentation of the first line and the error parser gets to the second line where the supplied argument is (true/false), which isn't possible and that's what probably crashes the engine.
Please fill in:
Godot version
THIS DOES NOT HAPPEN IF THE CODE IS WRITTEN BY HAND.
WHY NOT.
Can confirm on 9e0fbb49c
The crash happens here
because true/false is a division by zero.
False resolves to 0, doesn't it? true/false is then 1/0. Doesn't this mean that this isn't actually a bug?
It's a bug. The editor should have a check for this instead of crashing. Same for games in debug mode, for proper error reporting.
The crash is ok on release builds.
Closing this issue, as #11291 is more explicit about the problem :)
Most helpful comment
It's a bug. The editor should have a check for this instead of crashing. Same for games in debug mode, for proper error reporting.
The crash is ok on release builds.