Repository: godot
Issue: GDScript completion crashes when indexing a duplicate of the script from itself
Labels: bug,topic:gdscript,topic:editor,confirmed,crash

### Godot version

3.4.2.stable

### System information

Windows 10, AMD Ryzen 7 5800X, NVIDIA RTX 3080

### Issue description

While writing a script, **not while the game is running**, when duplicating a Node's script from within the same script and then trying to access that duplicate script causes a segfault. Please note that the game was not run, simply typing something in the editor causes the crash.

## Use case
I am dynamically creating new scripts at runtime. Instead of using a dummy node with a script attached, I thought it would be nice to simply duplicate the current node's script instead.

EDIT: I should mention that this works as expected is using a dummy node to copy from.

## ~~Stacktrace~~ Error log
```
$ ./Godot_v3.4.2-stable_win64.exe --editor --verbose --path ../dev/repl-gd/
Godot Engine v3.4.2.stable.official.45eaa2daf - https://godotengine.org
Using GLES3 video driver
OpenGL ES 3.0 Renderer: NVIDIA GeForce RTX 3080/PCIe/SSE2
OpenGL ES Batching: ON
        OPTIONS
        max_join_item_commands 16
        colored_vertex_format_threshold 0.25
        batch_buffer_size 16384
        light_scissor_area_threshold 1
        item_reordering_lookahead 4
        light_max_join_items 32
        single_rect_fallback False
        debug_flash False
        diagnose_frame False
WASAPI: wFormatTag = 65534
WASAPI: nChannels = 2
WASAPI: nSamplesPerSec = 48000
WASAPI: nAvgBytesPerSec = 384000
WASAPI: nBlockAlign = 8
WASAPI: wBitsPerSample = 32
WASAPI: cbSize = 22
WASAPI: detected 2 channels
WASAPI: audio buffer frames: 1962 calculated latency: 44ms

CORE API HASH: 2238588822097579888
EDITOR API HASH: 10291639213636549143
Construct gdnative interface

Destruct gdnative interface

Class 'BulletPhysicsDirectBodyState' is not exposed, skipping.
Class 'BulletPhysicsDirectSpaceState' is not exposed, skipping.
Class 'BulletPhysicsServer' is not exposed, skipping.
Class 'GDScriptNativeClass' is not exposed, skipping.
Class 'IP_Unix' is not exposed, skipping.
Class 'InputDefault' is not exposed, skipping.
Class 'Physics2DDirectBodyStateSW' is not exposed, skipping.
Class 'Physics2DDirectSpaceStateSW' is not exposed, skipping.
Class 'Physics2DServerSW' is not exposed, skipping.
Class 'ResourceImporterMP3' is not exposed, skipping.
Class 'ResourceImporterOGGVorbis' is not exposed, skipping.
Loading resource: C:/redacted ;)/editor_settings-3.tres
EditorSettings: Load OK!
Loaded builtin certs
EditorSettings: Save OK!
Loading resource: res://addons/repl-gd/standalone/dummy_plugin.gd
Loading resource: res://addons/repl-gd/fake_tree.gd
Loading resource: res://addons/repl-gd/plugin.gd
Loading resource: res://addons/repl-gd/repl.gd
Loading resource: res://addons/repl-gd/standalone/main_shim.tscn
Loading resource: res://addons/repl-gd/repl.tscn
Loading resource: res://addons/repl-gd/repl.tscn
Segmentation fault
```

### Steps to reproduce

Minimal reproduction code in a completely new project. There is no need to run the game.
```gdscript
extends Node

var dummy: GDScript

func _ready():
	dummy = get_script().duplicate()
	# start typing 'dummy.'
        # Typing the period character will cause a segfault
```

### Minimal reproduction project

[segfault-3.4.2.zip](https://github.com/godotengine/godot/files/8008512/segfault-3.4.2.zip)