Commit Graph

162 Commits

Author SHA1 Message Date
961b4ac5f5 GDScript: Fix wrong native type for preloaded class 2023-01-03 05:45:06 +02:00
bc739a4687 GDScript: Make using return of void function an error
Remove the `VOID_ASSIGNMENT` warning since those cases will be errors
now.
2022-12-30 13:35:38 -03:00
33afa82fb0 Merge pull request #70613 from vonagam/fix-enum-as-constant
Fixes https://github.com/godotengine/godot/issues/54018
Fixes https://github.com/godotengine/godot/issues/70213
Fixes https://github.com/godotengine/godot/issues/70495
2022-12-30 12:10:50 -03:00
9507f65e25 GDScript: Disallow return with value in void functions 2022-12-29 03:06:13 +02:00
b6aa4840d8 Fix usage of Enum as constant 2022-12-28 23:04:40 +02:00
f67aa3e46d GDScript: Fix return type of constructor call for extending class 2022-12-27 23:02:12 +02:00
ae4c025da9 Merge pull request #69991 from rune-scape/cast-type
GDScript: Fix cast producing null
2022-12-23 09:22:21 +01:00
edfa1e8665 Merge pull request #70220 from adamscott/fix-external-enum
Fix external enums not assignable as constants
2022-12-23 09:20:50 +01:00
e1657bd2a7 Merge pull request #70440 from rune-scape/null-again
Fix GDScript analyzer null literal
2022-12-22 16:02:19 +01:00
3228fdb88a Fix GDScript analyzer null literal 2022-12-22 06:02:34 -05:00
d93dbab054 Add MethodInfo to signal datatype 2022-12-21 22:49:51 -05:00
7fc814f697 Fix external enums not assignable as constants
- Add external enums test
- Rename external inner class test
- Clean up `GDScriptAnalyzer::reduce_identifier_from_base` class
  behavior
2022-12-17 17:59:38 -05:00
1bbb2b4159 Fix outer class lookup 2022-12-17 17:57:00 -05:00
2fefcf7329 Fix inner class constant assignment 2022-12-17 12:03:03 -05:00
213c94b42f Fix enum value regression 2022-12-16 22:48:25 -05:00
6debf86d51 Merge pull request #69471 from rune-scape/rune-out-of-order
GDScript: Out of order member resolution
2022-12-15 07:56:23 +01:00
2dfc6d5b69 GDScript: Allow out of order member resolution 2022-12-14 21:44:05 -05:00
7d0d6aa16f GDScript: Fix cast producing null 2022-12-12 19:57:26 -05:00
08449ab16e Fix String type compatibility being too permissive 2022-12-12 07:27:41 -05:00
65a49bad5a Fix constant base typing in extended GDScript class 2022-12-10 13:39:45 -05:00
e79be6ce07 Unify String and StringName 2022-12-05 21:46:47 -05:00
d1e4146462 Improve parent signature error 2022-12-01 15:16:16 +01:00
80b3813b15 Merge pull request #67714 from adamscott/fix-preload-cyclic-references-part2
Fix cyclic references in GDScript 2.0
2022-11-18 23:08:01 +01:00
5704055d30 Fix cyclic references in GDScript 2.0 2022-11-18 16:41:31 -05:00
13be0ab733 Fix ability to overload "script" variable 2022-11-17 17:21:12 -05:00
bce6f1792e GDScript compiler subclass bugfixes 2022-11-13 02:29:21 -08:00
291d3aaabe Improve null and object printing to avoid confusion with arrays
- Use different syntax for object printing to avoid confusion with arrays.
- Print null as `<null>` to avoid confusion with a string `"null"`.
- Display `<empty>` in editor resource pickers to avoid confusion
  with array-based properties.
2022-08-31 15:31:49 +02:00
f81a166ab8 fix(gdscript): Infer type from preload const
When resolving the type of the attribute from the variant, the result_type.kind was overritten for no reason.
It is assumed that this only needs to be done, if the variant value is not valid to have any kind here.

Solves #63715
2022-08-07 16:09:24 +02:00
6369e495fd Merge pull request #61279 from Trioct/fix-typed-array-assignment 2022-05-25 17:28:22 +02:00
bcbfa641ec Fix const typed array assignment 2022-05-25 09:02:11 -05:00
24bcbe971a GDScript: Don't show redundant await warning on unknown types
Also avoid it when the type is known to be a signal.
2022-05-24 14:37:50 -03:00
06a2d83e30 Add regression test for gdscript valid function signature
Previously, there was an issue where the gdscript analyzer incorrectly
riased a validation error for code that had a default Dictionary, Array,
or custom type.
2022-05-03 12:46:09 -07:00
b3704e664d Fixes GDScript define nested dictionary and array as constants #50285 2022-04-19 08:57:23 -04:00
1ebcb58e69 GDScript: Check if method signature matches the parent
To guarantee polymorphism, a method signature must be compatible with
the parent. This checks if:

1. Return type is the same.
2. The subclass method takes at least the same amount of parameters.
3. The matching parameters have the same type.
4. If the subclass takes more parameters, all of the extra ones have a
default value.
5. If the superclass has default values, so must have the subclass.

There's a few test cases to ensure this holds up.
2022-03-06 11:16:20 -03:00
ceafdf347e GDScript: Treat enum values as int and enum types as dictionary
Since enums resolve to a dictionary at runtime, calling dictionary
methods on an enum type is a valid use case. This ensures this is true
by adding test cases. This also makes enum values be treated as ints
when used in operations.
2022-02-03 13:32:34 -03:00
ad6e2e82a9 GDScript: Consolidate behavior for assigning enum types
This makes sure that assigning values to enum-typed variables are
consistent. Same enum is always valid, different enum is always
invalid (without casting) and assigning `int` creates a warning
if there is no casting.

There are new test cases to ensure this behavior doesn't break in
the future.
2022-02-03 13:32:16 -03:00
960a26f6c0 GDScript: Fix parsing default parameter values from function calls 2022-01-13 19:28:39 -05:00
fd643c903d GDScript: Add annotation to ignore warnings 2022-01-04 09:32:43 -03:00
540821a264 GDScript: Fix inferred typed array marked as constant 2021-10-15 10:40:50 -03:00
bf322bacdd Merge pull request #53726 from briansemrau/gd-outer-class
GDScript 2.0: Access outer scope classes
2021-10-14 10:12:52 -03:00
0ff0f64cd4 GDScript: Access outer scope classes 2021-10-13 22:39:12 -04:00
e4288bf728 Merge pull request #53720 from vnen/gdscript-typed-array-custom-class 2021-10-12 16:51:50 +02:00
34288b24a6 GDScript: Fix typed array with custom classes 2021-10-12 10:41:04 -03:00
45f546c1d8 GDScript: Make setter parameter type same as variable type 2021-10-12 09:39:23 -03:00
551ceb590b GDScript: Report property type errors
Inline getters & setters are now FunctionNodes.
Their names are set in the parser, not in the compiler.
GDScript-Analyzer will now run through getter and setter.
Also report wrong type or signature errors regarding getset properties.
Added GDScript tests for getters and setters.
#53102
2021-10-08 22:06:15 +02:00
98b81ad35c Merge pull request #53479 from vnen/gdscript-subscript-object-self 2021-10-06 19:48:23 +02:00
1f55bd190c GDScript: Allow subscript on self and object types 2021-10-06 12:01:34 -03:00
6bdb28f5e4 GDScript: Avoid hard errors on inferred types
Since inference isn't always correct, they are now treated as unsafe
instead of errors.

This also removes inferred type when a variable is reassigned. Since
it's not aware of branching, the types might become invalid in a later
context.
2021-10-06 11:42:19 -03:00
d6c799006a GDScript: Make all warnings enabled in test generation
The test generation doesn't initialize the language (since it's already
initialized in main), but it still needs the warning enabled so it
matches the actual tests.
2021-10-06 11:39:00 -03:00
72c07708e8 GDScript: Don't allow builtin type names as identifiers 2021-09-29 11:23:16 -03:00