Commit graph

378 commits

Author SHA1 Message Date
Rémi Verschelde
1a62f1e4fc
Merge pull request #74741 from vnen/variant-not-for-everyone
Allow boolean operators for all Variant types
2023-06-18 16:28:10 +02:00
Rémi Verschelde
4db1d09bf5
Merge pull request #73657 from mashumafi/callable-ctor
Fix: Get constructor as Callable
2023-06-18 16:27:42 +02:00
Rémi Verschelde
49b774e009
Merge pull request #77324 from anvilfolk/oh-no-its-virtual
GDScript: add errors when calling unimplemented virtual functions
2023-06-15 15:26:18 +02:00
Rémi Verschelde
25b2f1780a
Style: Harmonize header includes in modules
This applies our existing style guide, and adds a new rule to that style
guide for modular components such as platform ports and modules:

Includes from the platform port or module ("local" includes) should be listed
first in their own block using relative paths, before Godot's "core" includes
which use "absolute" (project folder relative) paths, and finally thirdparty
includes.

Includes in `#ifdef`s come after their relevant section, i.e. the overall
structure is:

- Local includes
  * Conditional local includes
- Core includes
  * Conditional core includes
- Thirdparty includes
  * Conditional thirdparty includes
2023-06-15 14:35:45 +02:00
ocean (they/them)
861743cd04 GDScript: add errors when calling unimplemented virtual functions
This PR does a small refactor of how method flags are handled in the GDScript analyzer.
This way, it adds support for the analyzer to use any of MethodInfo's flags, where previously
it could only use METHOD_FLAG_STATIC and METHOD_FLAG_VARARG.

As a side-effect, this also normalizes behavior between editor and release templates, which fixes #76938.

The tests added also brought a different issue to light, where using `super()` appears to generate a
return variable discarded on calling super's _init(), which doesn't have a return value. This should be
tackled in a different PR, which will have to change the output of this PR's tests.
2023-06-15 07:16:31 -04:00
Rémi Verschelde
3a319daa99
Merge pull request #77351 from anvilfolk/super-discard
GDScript: do not RETURN_VALUE_DISCARDED for `super()` inside `_init()`
2023-06-15 10:39:59 +02:00
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
ocean (they/them)
25c90836fd GDScript: do not warn of return value discarded for super() inside _init()
DO NOT BATCH MERGE WITH #77324, WILL RESULT IN BROKEN CI

Currently, calling super() inside _init() throws a
RETURN_VALUE_DISCARDED warning. The analyzer identifies super() as being a
constructor, which therefore returns an object of the relevant class.
However, super() isn't really a constructor by itself: in this case, it
is _part_ of the constructor, and so doesn't "return" a value.

A test case for this is already in #77324, which contains the warning. I
am duplicating it here, without the warning, and it should conflict with
the other PR.
2023-05-22 09:29:34 -04: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
George Marques
d76b3f2a4c
GDScript: Allow boolean operators between any types
To make consistent with previous behavior. Mostly to be used in
conditions for `if` and `while`.
2023-03-10 16:01:17 -03: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
mashumafi
b39b4010bd Fix: Get constructor as Callable 2023-02-20 22:05:54 -05: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