Commit graph

369 commits

Author SHA1 Message Date
Rémi Verschelde
8b62c52d1c
Merge pull request #75419 from vonagam/fix-super-classes-in-array-literals
GDScript: Allow elements of a parent class in a typed array literal
2023-06-14 09:23:32 +02:00
Danil Alexeev
3bf72be625
GDScript: Fix calling static func from non-static is allowed 2023-05-17 10:25:03 +03:00
Danil Alexeev
7da3110e6b
GDScript: Fix validate_call_arg() for unresolved datatype 2023-05-15 12:13:52 +03:00
Danil Alexeev
c2fbb40e9a
GDScript: Fix warning ignoring for member variables 2023-05-12 17:43:58 +03:00
Rémi Verschelde
f37fc4e708
Merge pull request #76412 from dalexeev/gds-reorganize-warnings
GDScript: Reorganize and unify warnings
2023-04-28 18:45:48 +02:00
Rémi Verschelde
f374390fc1
Merge pull request #75014 from vonagam/assert-literal-false
GDScript: Allow usage of literal false in assert without a warning
2023-04-28 18:45:00 +02:00
Danil Alexeev
13310f3557
GDScript: Reorganize and unify warnings 2023-04-28 18:25:11 +03:00
George Marques
0ba6048ad3
Add support for static variables in GDScript
Which allows editable data associated with a particular class instead of
the instance. Scripts with static variables are kept in memory
indefinitely unless the `@static_unload` annotation is used or the
`static_unload()` method is called on the GDScript.

If the custom function `_static_init()` exists it will be called when
the class is loaded, after the static variables are set.
2023-04-27 09:51:44 -03:00
Yuri Sizov
a7276f1ce0
Merge pull request #75691 from dalexeev/gds-fix-signature-generation
GDScript: Misc fixes and improvements for signature generation
2023-04-14 20:01:27 +02:00
Danil Alexeev
66279b98b6
GDScript: Add missing member type check when resolving extends 2023-04-10 17:16:07 +03:00
Danil Alexeev
9df96e97ea
GDScript: Misc fixes and improvements for signature generation
* Use type hints for `@GlobalScope` enums.
* Use plain `int` for `BitMask<T>`.
* Fix type hints for typed arrays.
* Use `Variant` and `void` type hints.
* Discard unnecessary class prefix.
2023-04-07 10:43:21 +03:00
Dmitrii Maganov
8655d979a1 GDScript: Allow elements of a parent class in a typed array literal 2023-03-28 13:47:24 +03:00
Yuri Sizov
215893ebca
Merge pull request #74949 from dalexeev/gds-fix-await-warning
GDScript: Fix false positive `REDUNDANT_AWAIT` warning
2023-03-20 19:14:15 +01:00
Yuri Sizov
5461b9976c
Merge pull request #74844 from vonagam/change-class-extends-parsing
GDScript: Change parser representation of class extends
2023-03-20 19:13:23 +01:00
Dmitrii Maganov
5d0b183822 GDScript: Allow usage of literal false in assert without a warning 2023-03-17 05:37:56 +02:00
Danil Alexeev
c0eeb32e38
GDScript: Fix false positive REDUNDANT_AWAIT warning 2023-03-16 14:04:14 +03:00
Dmitrii Maganov
4e34cf238a GDScript: Change parser representation of class extends 2023-03-13 01:40:13 +02:00
Dmitrii Maganov
703274fd04 GDScript: Fix missing warning for shadowing of built-in types 2023-03-13 00:49:34 +02:00
Dmitrii Maganov
638aa4f811 GDScript: Fix wrong unsafety mark for binary operator 2023-02-26 01:35:53 +02:00
Dmitrii Maganov
55c5774be9 GDScript: Fix range regression 2023-02-24 00:35:11 +02:00
Dmitrii Maganov
7ee011051a GDScript: Fix usage of enum value as range argument 2023-02-23 10:38:53 +02:00
Dmitrii Maganov
2a08739f30 GDScript: Fix error message for unfound type 2023-02-21 23:00:29 +02:00
Rémi Verschelde
253396ba39
Merge pull request #73693 from vnen/gdscript-fix-script-signature-check
GDScript: Fix override signature check of script inheritance
2023-02-21 21:19:39 +01:00
George Marques
1731010774
GDScript: Fix override signature check of script inheritance
Avoid treating the super class as a meta type for signature check, since
it is looking at the instance level for that.
2023-02-21 14:37:08 -03:00
George Marques
91b93465d5
GDScript: Fix crash when autoload script can't be found 2023-02-21 10:45:24 -03:00
Rémi Verschelde
2057d7344e
Merge pull request #73590 from vnen/gdscript-global-scope-enums
Make global scope enums accessible as types in GDScript
2023-02-20 15:41:45 +01:00
Rémi Verschelde
561d949739
Merge pull request #73489 from vonagam/type-check-node
GDScript: Rework type check
2023-02-20 15:41:36 +01:00
Rémi Verschelde
6bf63a3542
Merge pull request #73291 from vonagam/fix-unsafe-weak-binop
GDScript: Fix missing unsafety mark for binary op with weak variables
2023-02-20 15:41:32 +01:00
George Marques
75f16b8167
Make global scope enums accessible as types in GDScript
Add functions to CoreConstant so enums can be properly deduced. Also add
the enums in release builds to make consistent with ClassDB enums and
avoid differences in script compilation between debug and release.
2023-02-19 13:00:07 -03:00
Dmitrii Maganov
8fe023ad93 GDScript: Rework type check 2023-02-17 19:57:18 +02:00
Yuri Sizov
6e0dd6beca
Merge pull request #72925 from vonagam/fix-enum-typed-array-error
GDScript: Fix error about enum typed arrays
2023-02-17 16:47:50 +03:00
Dmitrii Maganov
5972ba17a4 GDScript: Fix infer on read-only property 2023-02-16 15:50:17 +02:00
Danil Alexeev
8d3e682f52
GDScript: Fix default value of exported enum variable 2023-02-14 18:07:50 +03:00
Dmitrii Maganov
df6aae2eca GDScript: Fix missing unsafety mark for binary op with weak variables 2023-02-14 17:01:21 +02:00
Rémi Verschelde
e19e6b09b9
Clean up ProjectConverter3To4 architecture, move renames map to separate file
This allows properly limiting what features depend on the RegEx module
(doing the actual conversion) and what features only require the renames
data (GDScript suggestions).

Also better excludes the conversion command line options when actually
disabling deprecated code.

Fixes #73029.
2023-02-10 14:35:22 +01:00
Dmitrii Maganov
cedc5fa823 GDScript: Fix error about enum typed arrays 2023-02-09 00:31:40 +02:00
Markus Sauermann
826e54fa73 Some code simplifications
1. `number_width` isn't used later
2. `return_type` is used only once
3. AudioServer::get_singleton()->get_channel_count() always returns a channel_count of 1 or larger
4. negative `aa->backward` conditional
5. `current_canvas` == `find_world_2d()->get_canvas()`
6. identical if `render_shadows`
2023-02-07 14:30:16 +01:00
Danil Alexeev
685db28e29
GDScript: Fix await type inference 2023-02-06 23:02:14 +03:00
Yuri Sizov
d201df1ffa
Merge pull request #72512 from vonagam/fix-ternary-type-source
GDScript: Fix type certainty for result of ternary operator
2023-02-06 19:41:27 +03:00
Yuri Sizov
13f0158e49
Merge pull request #72608 from vnen/gdscript-warning-default-error
GDScript: Add warnings that are set to error by default (take 2)
2023-02-05 16:00:26 +03:00
George Marques
273bf7210f
GDScript: Add warnings that are set to error by default
- Adds a list of default levels for all warning so they can be set
  individually.
- Add warnings set by default to error for:
  - Using `get_node()` without `@onready`.
  - Using `@onready` together with `@export`.
  - Inferring a static type with a Variant value.
  - Overriding a native engine method.
- Adjust how annotations to ignore warnings are treated so they also
  apply to method parameters.
- Clean up a bit how ignored warnings are set. There were two sets but
  only one was actually being used.
- Set all warnings to the `WARN` level for tests, so they they can be
  properly tested.
- Fix enum types in native methods signatures being set to `int`.
- Fix native enums being treated as Dictionary by mistake.
- Make name of native enum types use the class they are defined in, not
  the direct super class of the script. This ensures they are always
  equal even when coming from different sources.
- Fix error for signature mismatch that was only showing the first
  default argument as having a default. Now it shows for all.
2023-02-02 12:07:25 -03:00
George Marques
5fc7918594
GDScript: Improve usability of setter chains
- Consider PackedArrays non-shared since they are copied on C++/script
  boundaries.
- Add error messages in the analyzer when assigning to read-only
  properties.
- Add specific error message at runtime when assignment fails because
  the property is read-only.
2023-02-02 10:20:35 -03:00
Dmitrii Maganov
7b04e3865a GDScript: Fix getting reduced value of incomplete subscript 2023-02-02 02:15:26 +02:00
Dmitrii Maganov
1a810ff45e GDScript: Fix type certainty for result of ternary operator 2023-02-01 14:52:29 +02:00
Rémi Verschelde
afe3b94ab2
Revert "GDScript: Add warnings that are set to error by default"
This reverts commit a166833bfa.

This caused multiple regressions.
Needs to be redone with more testing before merge.

Fixes #72501.
2023-02-01 10:54:22 +01:00
George Marques
a166833bfa
GDScript: Add warnings that are set to error by default
- Adds a list of default levels for all warning so they can be set
  individually.
- Add warnings set by default to error for:
  - Using `get_node()` without `@onready`.
  - Using `@onready` together with `@export`.
  - Inferring a static type with a Variant value.
  - Overriding a native engine method.
- Adjust how annotations to ignore warnings are treated so they also
  apply to method parameters.
- Clean up a bit how ignored warnings are set. There were two sets but
  only one was actually being used.
- Set all warnings to the `WARN` level for tests, so they they can be
  properly tested.
- Fix enum types in native methods signatures being set to `int`.
- Fix native enums being treated as Dictionary by mistake.
- Make name of native enum types use the class they are defined in, not
  the direct super class of the script. This ensures they are always
  equal even when coming from different sources.
- Fix error for signature mismatch that was only showing the first
  default argument as having a default. Now it shows for all.
2023-02-01 00:05:14 -03:00
Rémi Verschelde
925784df03
Merge pull request #72454 from dalexeev/gds-fix-icon-annotation
GDScript: Fix `@icon` annotation
2023-01-31 15:58:49 +01:00
Rémi Verschelde
6d9c9d30b9
Merge pull request #72206 from vnen/gdscript-allow-void-return-shorthand
GDScript: Allow void functions to return calls to other void functions
2023-01-31 15:55:35 +01:00
Rémi Verschelde
361f3f1721
Merge pull request #57520 from jordigcs/gd-rename-map
Add hint for identifiers renamed from 3.x to 4.0
2023-01-31 15:55:25 +01:00
Danil Alexeev
83cb968965
GDScript: Fix @icon annotation 2023-01-31 17:43:54 +03:00