Repository: godotengine/godot (language: cpp)

Issue:
Loading resources containing typed `Dictionary`s with values of type `Resource` causes a parse error
### Tested versions

- Reproducible in v4.4.dev2 [97ef3c837] and later snapshots (tested in v4.4.dev2, v4.4.dev5, v4.4.dev6, and v4.4.dev7)
- Not reproducible in earlier versions, as support for typed dictionaries had not been added yet.

### System information

Godot v4.4.dev7 - Windows 10 (build 19045) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated Quadro M2200 - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (8 threads)

### Issue description

When using the `load` function to load a .tres file containing a typed `Dictionary` with values of type `Resource` (e.g. `Dictionary[int, Resource]`), the resource fails to load and the following errors are present:
```
E 0:00:01:0172   main.gd:5 @ _ready(): user://save.tres:7 - Parse Error: Expected ']'
  <C++ Source>   scene/resources/resource_format_text.cpp:41 @ _printerr()
  <Stack Trace>  main.gd:5 @ _ready()

E 0:00:01:0172   main.gd:5 @ _ready(): Failed loading resource: user://save.tres. Make sure resources have been imported by opening the project in the editor at least once.
  <C++ Error>    Condition "found" is true. Returning: Ref<Resource>()
  <C++ Source>   core/io/resource_loader.cpp:323 @ _load()
  <Stack Trace>  main.gd:5 @ _ready()
```
The expected behavior is that the resource loads successfully without errors.

The issue does not occur when using a class that inherits `Resource`. For example, using a custom class called `CustomResource` that extends `Resource` will not cause the error.

Additionally, adding an extra mismatched closing square bracket to the .tres file stops the error as well:
```
data = Dictionary[int, Resource]]({})
```

### Steps to reproduce

1. Download and open the minimal reproduction project
2. Run the project
3. Check the Errors tab of the debugger, the above errors appear
4. In `SaveData.gd`, replace `Dictionary[int, Resource]` with `Dictionary[int, CustomResource]`
5. Run the project again and check the debugger, the errors are no longer thrown

### Minimal reproduction project (MRP)

[resource-loading-error.zip](https://github.com/user-attachments/files/18268655/resource-loading-error.zip)



Discussion / hints:

Fix patch:
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index 2cae430bfbca..a53da4eabcb2 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -1223,7 +1223,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
 						r_err_str = String();
 						value_type = Variant::OBJECT;
 						value_class_name = token.value;
-						got_comma_token = true;
+						got_bracket_token = true;
 					} else {
 						return err;
 					}


Test patch: