Rémi Verschelde
317cd0b19a
Refactor some object type checking code with `cast_to`
...
Less stringly typed logic, and less String allocations and comparisons.
2022-02-08 10:08:34 +01:00
Rémi Verschelde
89eb6d372d
Merge pull request #57591 from vnen/gdscript-enum-fixes
2022-02-04 13:49:15 +01:00
George Marques
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
George Marques
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
cdemirer
28ac4d8b7d
Fix crash with non-constant keys in match statement Dictionary pattern
2022-01-26 04:10:07 +08:00
Rémi Verschelde
4cfade6212
Merge pull request #55995 from Xwdit/enum_fix
...
Fix enum int comparison
2022-01-17 20:20:16 +01:00
Rémi Verschelde
1989120d3f
Merge pull request #56194 from cdemirer/fix-operation-result-type-inference
2022-01-10 17:18:32 +01:00
Rémi Verschelde
4acc819f9b
Merge pull request #56232 from V-Sekai/invalid_explicit_variant_assign_fix
2022-01-10 17:12:56 +01:00
Rémi Verschelde
cc7f634066
Merge pull request #56260 from cdemirer/fix-type-mutation-upon-assignment-with-operation
2022-01-10 17:12:34 +01:00
Rémi Verschelde
6d4ed65f4c
Merge pull request #56483 from vnen/gdscript-warning-annotation
...
Add annotation to ignore warnings
2022-01-05 09:05:56 +01:00
George Marques
fd643c903d
GDScript: Add annotation to ignore warnings
2022-01-04 09:32:43 -03:00
Rémi Verschelde
fe52458154
Update copyright statements to 2022
...
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
cdemirer
067b4c8c07
Fix type mutation upon compound assignment
2021-12-27 03:32:22 +08:00
SaracenOne
b22c805dbe
Fix 'Compiler bug: unresolved assign' on explicitly annotated variants.
2021-12-25 00:53:57 +00:00
cdemirer
455cc07f90
Fix operation result type inference
2021-12-23 20:45:24 +08:00
Xwdit
0430e26e6d
Fix enum int comparison
...
Fix enum int comparison
2021-12-16 16:14:14 +01:00
Gilles Roudière
ab8119b5f6
Avoid a crash in the gdscript analyser
2021-12-14 15:54:25 +01:00
Yuri Roubinsky
566895732c
Fix shadowed global identifier warning duplication
2021-12-13 11:54:23 +03:00
kobewi
4682f22293
Improve various texts
2021-11-23 12:20:57 +01:00
Benjamin Navarro
560d9a4cc0
Fix incorrect debug check for setters
...
the check read the return type of the setter, which doesn't exist and
lead to a segmentation fault. Now we check the first function parameter.
Probably a bad copy/paste of the getter case
2021-10-18 09:01:16 +02:00
Rémi Verschelde
3f888966c0
Merge pull request #53843 from vnen/gdscript-typed-array-subscript-constant
...
Fix inferred typed array marked as constant
2021-10-15 16:49:29 +02:00
George Marques
540821a264
GDScript: Fix inferred typed array marked as constant
2021-10-15 10:40:50 -03:00
George Marques
84abb9a76c
GDScript: Fix typing for await expression
...
Don't grab the type of the awaited value unless it's constant (which
makes it synchronous) or call (which always use the proper return type).
2021-10-14 20:30:06 -03:00
George Marques
749d89ae38
GDScript: Remove error when coroutine is called without await
...
In the case the call happens as a statement, since the return value
isn't used in this case.
2021-10-14 20:12:01 -03:00
George Marques
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
Brian Semrau
0ff0f64cd4
GDScript: Access outer scope classes
2021-10-13 22:39:12 -04:00
Rémi Verschelde
e4288bf728
Merge pull request #53720 from vnen/gdscript-typed-array-custom-class
2021-10-12 16:51:50 +02:00
George Marques
34288b24a6
GDScript: Fix typed array with custom classes
2021-10-12 10:41:04 -03:00
George Marques
45f546c1d8
GDScript: Make setter parameter type same as variable type
2021-10-12 09:39:23 -03:00
ZuBsPaCe
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
George Marques
3a856b4fcc
GDScript: Use getter return type for the property type
...
The PropertyInfo hints are more relevant for the inspector. The getter
return type is more reliable and less likely to be incorrect and it is
what's going to be called in the end.
2021-10-07 20:22:19 -03:00
Rémi Verschelde
98b81ad35c
Merge pull request #53479 from vnen/gdscript-subscript-object-self
2021-10-06 19:48:23 +02:00
George Marques
1f55bd190c
GDScript: Allow subscript on self and object types
2021-10-06 12:01:34 -03:00
George Marques
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
George Marques
7725ebf3d2
GDScript: Use path cache when checking preloaded scripts
...
The path itself might not always be set in some cases, especially when
the script is just created and is already in the resource cache. Using
get_path() in this case gets the correct resource path.
This also adds a null check for safety in case the path is incorrect or
missing, to avoid a crash in the engine.
2021-10-04 20:48:39 -03:00
Rémi Verschelde
4a4995524c
Merge pull request #53338 from briansemrau/gdscript-handle-for-with-null-list
2021-10-04 17:11:43 +02:00
kobewi
cb28469281
Allow void as return type for constructors
2021-10-03 21:16:54 +02:00
Brian Semrau
dc046e5cbe
GDScript Check for null list in `for` loop
2021-10-02 13:53:56 -04:00
Lightning_A
c63b18507d
Use range iterators for `Map`
2021-09-30 15:09:12 -06:00
Rémi Verschelde
d2b8560d7a
Revert "GdScript: Use reduced constant expression result when doing binary operations. Fixes #50293"
...
This reverts commit 6207708607
.
It broke a GDScript test (which didn't exist back when the PR was made,
so was missed prior to the merge).
It choked on:
```
prints("a", test_instance.a, test_instance.a == Named.VALUE_A)
```
With:
```
Invalid operands "VALUE_A (enum value)" and "int" for "==" operator.
```
2021-09-30 18:57:59 +02:00
Rémi Verschelde
7f8e50801e
Merge pull request #51818 from MarianoGnu/gdscript2-enum-fixes
2021-09-30 18:35:49 +02:00
George Marques
72c07708e8
GDScript: Don't allow builtin type names as identifiers
2021-09-29 11:23:16 -03:00
George Marques
5107f9190b
GDScript: Remove conversion assign mistakenly done when unneeded
2021-09-21 11:58:57 -03:00
George Marques
b8fdeb6467
Merge pull request #51671 from RandomShaper/fix_gdscript_crash
...
Fix some GDScript bugs
2021-09-17 12:29:40 -03:00
George Marques
4e69341c01
GDScript: Avoid inferred types from giving hard errors
2021-09-17 11:52:30 -03:00
George Marques
a5c299630d
Merge pull request #50456 from Blackiris/fix-extends-parent-relative
...
Fix extends with relative path to parent script
2021-09-15 11:12:24 -03:00
Rémi Verschelde
c23823ac54
Merge pull request #52582 from jmb462/Prevent-non-explicit-inferring-parameter-from-null
2021-09-15 15:50:42 +02:00
Rémi Verschelde
45d9df2e63
Merge pull request #52632 from vnen/autoload-global-script-class-conflict
...
Disallow class names to be the same as global names
2021-09-13 21:10:50 +02:00
Rémi Verschelde
0c2ab55a58
Merge pull request #52100 from vnen/gdscript-access-outer-constants
...
GDScript: Allow access to outer constant and enum values
2021-09-13 18:04:35 +02:00
George Marques
2e5fa124f4
Disallow class names to be the same as global names
...
Also forbid autoloads to have the same name as global script class.
2021-09-13 10:51:29 -03:00