Godot version:
Tested on nightly build and 3.1.1
OS/device including version:
GNU/Linux x64
Issue description:
The engine seems to only throw an error when using get_tree().root.foo = bar, I tried with another object and the script ran fine.

Steps to reproduce:
use get_tree().root.foo = bar in a script
Minimal reproduction project:
GDScriptBug.zip
Possibly because you are trying to access a parent node in _ready within the games main scene. The scenetrees root viewport may not have readied by then.
Possibly because you are trying to access a parent node in _ready within the games main scene. The scenetrees root viewport may not have readied by then.
Probably not since storing the root in a variable and using it works as shown in the code at the bottom and doing the same in _process also causes an error.
Calling get_root() method directly works:
get_tree().get_root().render_target_v_flip = true
When attempted with property, strangely the following hack works: :eyes:
((get_tree().root) as Viewport).render_target_v_flip = true
(this casts the root to viewport before accessing)
The following prints true, though:
print(get_tree().root is Viewport) # true
I think I commented this on another issue.
If you set the last value "property chain" like this
a.b.c.d = new_val_d
Godot will update each property in reverse. Once the d value is set for c the updated value for c will be set for b and then b for a. Like the code gets transformed to this:
var b = a.b
var c = b.c
c.d = new_val_d
b.c = c
a.b = b
So in your code Godot sets a property for root and tries to call get_tree().root = root but the latter is an invalid operation (only read access).
It's been a while though and I don't remember exactly where this behavior applies in GDScript. I think this covers the C++ code that is just exposed.
Calling a get-method will break the chain and is a valid workaround.
Most helpful comment
I think I commented this on another issue.
If you set the last value "property chain" like this
Godot will update each property in reverse. Once the
dvalue is set forcthe updated value forcwill be set forband thenbfora. Like the code gets transformed to this:So in your code Godot sets a property for
rootand tries to callget_tree().root = rootbut the latter is an invalid operation (only read access).It's been a while though and I don't remember exactly where this behavior applies in GDScript. I think this covers the C++ code that is just exposed.
Calling a get-method will break the chain and is a valid workaround.