Commit graph

533 commits

Author SHA1 Message Date
ocean (they/them) 5d164df4e1 Make type not found errors more informative.
This PR removes a check for whether a datatype is a meta type when
generating a datatype's to_string() result. This means that error
messages that fail to find the type will now print their class names,
which is much more useful when trying to identify errors.
2023-04-02 18:30:30 -04: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
Danil Alexeev ea5fd3d732
Fix GDScript code style regarding colon 2023-03-05 17:03:20 +03:00
Rémi Verschelde 491ded1898
Minor typo and docs URL fixes 2023-02-28 13:38:01 +01:00
Rémi Verschelde c0f1ed57c4
Merge pull request #73915 from vonagam/fix-conversions-from-native-member
GDScript: Fix conversions from native members accessed by identifier
2023-02-26 19:02:27 +01:00
Rémi Verschelde c118790eb9
Merge pull request #73899 from vnen/gdscript-init-defaults-beforehand
GDScript: Initialize all defaults beforehand in implicit constructor
2023-02-26 15:59:27 +01:00
George Marques eba984a44f
Revert "GDScript: Fix groups and categories been seen as members"
This reverts commit 6f2a8434c6.

The commit introduces a bug where it creates spurious entries for member
information.
2023-02-25 13:40:31 -03:00
Dmitrii Maganov 281c8c75d3 GDScript: Fix conversions from native members accessed by identifier 2023-02-25 10:53:36 +02:00
George Marques 0e6aa6fc38
GDScript: Initialize all defaults beforehand in implicit constructor
Set all the default values for typed variables before actually trying to
initialize them, including `@onready` ones.

This ensures that if validated calls are being used there will be a
value of the correct type, even if the resolution is done out of order
or deferred because of `@onready`.
2023-02-24 22:01:06 -03:00
George Marques defa46bfd1
GDScript: Don't use validated call for vararg methods
Since they may have runtime type validation, we cannot use the validated
call.
2023-02-24 14:06:02 -03:00
Rémi Verschelde a6baebc7c2
Fixup GDScript test using non-deterministic ids
Follow-up to #73870.
2023-02-24 14:31:36 +01:00
Rémi Verschelde 7e00cc1f7a
Merge pull request #73870 from vnen/gdscript-dont-reference-group-properties
GDScript: Fix groups and categories been seen as members
2023-02-24 14:08:20 +01:00
George Marques 6f2a8434c6
GDScript: Fix groups and categories been seen as members 2023-02-24 10:03:12 -03:00
Dmitrii Maganov 55c5774be9 GDScript: Fix range regression 2023-02-24 00:35:11 +02:00
Rémi Verschelde 76d80c2cba
Merge pull request #73798 from vonagam/fix-bad-continue-in-lambda
GDScript: Fix parsing unexpected break/continue in lambda
2023-02-23 13:54:56 +01:00
Dmitrii Maganov b0b1eaeb6d GDScript: Fix parsing unexpected break/continue in lambda 2023-02-23 10:49:06 +02:00
Dmitrii Maganov 7ee011051a GDScript: Fix usage of enum value as range argument 2023-02-23 10:38:53 +02:00
mashumafi 2a12213c31 Fix: Typed arrays aren't working with + 2023-02-22 18:42:26 -05:00
Rémi Verschelde 56622b8ec3
Merge pull request #73709 from vonagam/fix-error-message-unfound-type
GDScript: Fix error message for unfound type
2023-02-21 23:36:29 +01:00
Rémi Verschelde d4bec5855e
Merge pull request #73705 from anvilfolk/doublewoopsie
Added check for null objects in gdscript typed assign.
2023-02-21 23:36:06 +01:00
Dmitrii Maganov 2a08739f30 GDScript: Fix error message for unfound type 2023-02-21 23:00:29 +02:00
ocean (they/them) 9ddf482a06 Added check for null objects in gdscript typed assign. 2023-02-21 15:29:07 -05: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
mashumafi 8eb837dc3d Add test for const class references 2023-02-20 23:01:32 -05: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 ea2bc9795c
Merge pull request #73544 from mashumafi/fix-func-arg-null
Fix: Func with typed args error when arg is null
2023-02-20 15:41:40 +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
mashumafi 30d4d3fa5e Fix: Func with typed args error when arg is null 2023-02-19 21:47:48 -05: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
ocean (they/them) 9eb4d1e4bf Fix inability to assign null regression
Co-authored-by: Dmitry Maganov <vonagam@gmail.com>
2023-02-17 11:45:56 -05: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
Rémi Verschelde 68807165f4
Merge pull request #73398 from anvilfolk/fix-getter
Fix unset getter return types resulting in strange behavior
2023-02-17 00:31:42 +01:00
ocean (they/them) c45970739e Fix crash by freed object assign to typed variable 2023-02-16 15:17:46 -05:00
ocean (they/them) 94dfac8da7 Add return type for GDScript getters 2023-02-15 17:54:38 -05:00
Danil Alexeev d15511725a
GDScript: Fix MIN_INT not representable as numeric literal 2023-02-15 17:41:46 +03:00
Dmitrii Maganov 9cb2da89d6 GDScript: Fix usage of ints with typed array of floats 2023-02-13 22:06:38 +02:00
Rémi Verschelde dc7f08b556
Merge pull request #72971 from vnen/gdscript-multiline-comment
GDScript: Allow strings as multiline comments
2023-02-09 16:19:03 +01:00
George Marques 03ea77407c
GDScript: Be more lenient with identifiers
- Allow identifiers similar to keywords if they are in ASCII range.
- Allow constants to be treated as regular identifiers.
- Allow keywords that can be used as identifiers in expressions.
2023-02-09 11:19:05 -03:00
George Marques f95967c299
GDScript: Allow strings as multiline comments
Bring back the behavior in 3.x that was left out by oversight.
2023-02-09 10:16:00 -03:00
Dmitrii Maganov cedc5fa823 GDScript: Fix error about enum typed arrays 2023-02-09 00:31:40 +02:00
Rémi Verschelde 98921d8fba
Revert "Remove script class checks when getting function signature"
This reverts commit 0fef203b1f.

This introduced some other issues, as discussed in #72144.
2023-02-07 16:28:52 +01:00
Adam Scott 0fef203b1f
Remove script class checks when getting function signature 2023-02-07 11:48:10 +01:00
Yuri Sizov 945207885b
Merge pull request #72546 from vonagam/fix-typed-array-can-reference
GDScript: Fix can_reference check for typed arrays
2023-02-06 23:32:47 +03:00
Yuri Sizov c0edea37ef
Merge pull request #72677 from dalexeev/gds-await-infer-type
GDScript: Fix `await` type inference
2023-02-06 23:32:28 +03:00
Yuri Sizov 7b86a082be
Merge pull request #72804 from vnen/gdscript-no-onready-without-node
GDScript: Fix inheritance check of @onready for inner classes
2023-02-06 23:03:44 +03:00
Danil Alexeev 685db28e29
GDScript: Fix await type inference 2023-02-06 23:02:14 +03:00
Dmitrii Maganov 8400308ab3 GDScript: Fix can_reference check for typed arrays 2023-02-06 22:00:16 +02:00
George Marques ed5ddab7e5
GDScript: Fix inheritance check of @onready for inner classes 2023-02-06 14:52:13 -03:00
Rémi Verschelde 2fdaf2919c
GDScript: Fix recently merged test not ignoring warnings 2023-02-06 18:19:34 +01: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
George Marques 3941af3d91
GDScript: Don't allow @onready without inheriting Node 2023-02-06 10:45:38 -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 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
George Marques a47d4d57ca
GDScript: Allow void functions to return calls to other void functions 2023-01-31 11:37:30 -03:00
Rémi Verschelde e768e02b78
Merge pull request #72444 from reduz/fix-global-class-parsing
Fix global script class parsing.
2023-01-31 13:20:00 +01:00
Juan Linietsky 1bbe0a2b2f Fix global script class parsing.
* Broke with #72226
* Restored previous version of the code, made it even more error tolerant.
* Added a warning to **not** change the code.

Fixes #72226.
2023-01-31 12:43:25 +01:00
Rémi Verschelde 99a44f8469
Merge pull request #69248 from vonagam/fixing-typed-arrays
GDScript: Fix typed arrays
2023-01-31 11:04:21 +01:00
Dmitrii Maganov 5909f9f075 GDScript: Fix issues with typed arrays 2023-01-31 11:54:41 +02:00
Rémi Verschelde b6a8b8e8f7
Merge pull request #72212 from anvilfolk/gdtestnames
Add option to print filenames in GDScript unit testing
2023-01-31 10:53:28 +01:00
ocean (they/them) 199e5dbb1e Add option to print filenames in GDScript unit testing 2023-01-30 22:20:45 -05:00
Dmitrii Maganov 011b3895db GDScript: Fix vararg method calls with exact arguments 2023-01-30 19:38:07 +02:00
Danil Alexeev d4b78c352f
GDScript: Fix @export_enum works only with int 2023-01-30 12:30:37 +03:00
Rémi Verschelde a3dae9e548
Merge pull request #72285 from vnen/gdscript-variable-match
GDScript: Allow variables in match patterns
2023-01-29 02:45:48 +01:00
Rémi Verschelde 9420116f6c
Merge pull request #72286 from vnen/gdscript-native-static-call-crash
GDScript: Avoid calling non-static methods on native classes
2023-01-29 02:23:55 +01:00
Rémi Verschelde 4011a0915e
Merge pull request #71844 from vonagam/fix-constant-conversions
GDScript: Fix constant conversions
2023-01-29 02:18:57 +01:00
George Marques aee7b7363b
GDScript: Avoid calling non-static methods on native classes 2023-01-28 20:33:01 -03:00
George Marques c68b2358d5
GDScript: Allow variables in match patterns
To restore an ability available in 3.x and reduce compatibility changes.
2023-01-28 19:53:27 -03:00
Dmitrii Maganov 31e0ae2012 GDScript: Fix constant conversions 2023-01-29 00:01:53 +02:00
Dmitrii Maganov 6194a7e0fa GDScript: Fix implicit conversions for function returns 2023-01-28 23:56:07 +02:00
Rémi Verschelde 218bef90af
GDScript: Fix test from #69163 after annotations change 2023-01-28 17:01:19 +01:00
Rémi Verschelde cc6e8379d4
Merge pull request #69163 from vonagam/variant-safe-lines
GDScript: Fix wrong marking of some lines related to Variant as unsafe
2023-01-28 15:40:19 +01:00
Dmitrii Maganov abe6d67232 GDScript: Fix test for read-only state of constants 2023-01-27 05:28:08 +02:00
Danil Alexeev b004f8180e
GDScript: Allow constant expressions in annotations 2023-01-25 18:43:56 +03:00
Rémi Verschelde 41e5f5b093
Merge pull request #71349 from vonagam/disallow-infer-on-weak
GDScript: Disallow type inference with untyped initializer
2023-01-25 14:42:20 +01:00
Danil Alexeev 13215638a9
Clarify error message about script-level annotation 2023-01-24 13:10:45 +03:00
Rémi Verschelde 81fe3715b8
Merge pull request #71914 from vnen/gdscript-no-continue-match
GDScript: Remove function of `continue` for match statement
2023-01-23 15:35:55 +01:00
George Marques 9462ae4783
GDScript: Remove function of continue for match statement
The keyword is confusing and rarely is used in the intended way. It is
removed now in favor of a future feature (pattern guards) to avoid
breaking compatibility later.
2023-01-22 18:45:24 -03:00
George Marques 7548e043fc
Add support for Unicode identifiers in GDScript
This is using an adapted version of UAX#31 to not rely on the ICU
database (which isn't available in builds without TextServerAdvanced).
It allows most characters used in diverse scripts but not everything.
2023-01-21 13:39:40 -03:00
ocean (they/them) 4854e723be Fix unnammed enum crash regression 2023-01-18 09:35:48 -05:00
Rémi Verschelde 4005fc4b8d
Merge pull request #71279 from vonagam/fix-iterator-number-type
GDScript: Fix typing of iterator in for loop
2023-01-16 22:21:26 +01:00
Rémi Verschelde 1c3653e083
Merge pull request #67774 from aaronfranke/script-annotations
Make script annotations be placed before `class_name` and `extends`
2023-01-16 22:20:44 +01:00
Yuri Sizov 4c1f11944e Update all outdated online documentation links 2023-01-14 19:38:00 +03:00
Dmitrii Maganov a1e0281b45 GDScript: Disallow type inference with untyped initializer 2023-01-13 20:51:29 +02:00
Dmitrii Maganov 40613ebd21 GDScript: Fix typing of iterator in for loop 2023-01-13 15:36:11 +02:00
Rémi Verschelde aaa5158ff9
Merge pull request #70733 from vonagam/fix-assigning-untyped
GDScript: Fix some issues with assignments that involve untyped things
2023-01-12 20:08:55 +01:00
Rémi Verschelde 40b9c246b6
Merge pull request #71197 from adamscott/add-default-virtual-path-gdscript
Add default virtual `gdscript://` path to `GDScript` instances
2023-01-12 17:56:09 +01:00
Rémi Verschelde def592114f
Merge pull request #70700 from vonagam/fix-abstract-extends
GDScript: Fix extending abstract classes, forbid their construction
2023-01-12 17:19:51 +01:00
Dmitrii Maganov 274d49790d GDScript: Fix extending abstract classes, forbid their construction 2023-01-12 17:47:10 +02:00
Adam Scott e3e55b29ce Add default virtual gdscript:// path to GDScript instances 2023-01-12 10:27:38 -05:00
Dmitrii Maganov ef81b344be GDScript: Fix wrong marking of some lines related to Variant as unsafe 2023-01-12 17:21:33 +02:00
Dmitrii Maganov 38c214d483 GDScript: Fix some issues with assignments that involve untyped things 2023-01-12 17:07:45 +02:00
Rémi Verschelde c6f4c0ac54
Merge pull request #70899 from adamscott/fix-vector-inf
Fix parse error using Vector{2,3,4}.INF
2023-01-12 15:59:01 +01:00
Dmitrii Maganov 5980abbcec GDScript: Fix getting type from PropertyInfo for Variant arguments 2023-01-12 16:47:06 +02:00
George Marques 75515e4303
Merge pull request #70987 from vonagam/fix-parameter-conversion-assign 2023-01-12 11:34:13 -03:00
George Marques 7319fa6082
Merge pull request #70713 from vonagam/fix-unnamed-enum-outer-conflicts 2023-01-12 11:22:01 -03:00
George Marques 66fda2aeea
GDScript: Fix temp values being written without proper clear
Temporary values in the stack were not being properly cleared when the
return value of calls were discarded, which can cause memory issues
especially for reference types like PackedByteArray.
2023-01-11 14:24:23 -03:00
Rémi Verschelde 5eb161a9c8
Merge pull request #70595 from adamscott/add-gdscript-editorconfig
Add GDScript `.editorconfig` rules
2023-01-11 01:10:10 +01:00
George Marques 04d0e851ea
GDScript: Fix use of conversion assign for variant values 2023-01-10 20:01:11 -03:00
Adam Scott 44d1d72af1 Add GDScript .editorconfig rules
- Uniformize `.gd` unit test files indentation to tabs (where needed)
2023-01-10 12:25:35 -05:00
Rémi Verschelde c894edd4cb
Merge pull request #71140 from vonagam/fix-const-index-subscript-type
GDScript: Fix type for index subscript on constant
2023-01-10 07:58:29 +01:00
Dmitrii Maganov ff505c9875 GDScript: Fix type for index subscript on constant 2023-01-10 07:10:00 +02:00
Adam Scott fb175d92da Fix GDScript base and outer classes, signals and functions lookup order
- Add outer class lookup test
- Add signal lookup test

Co-authored-by: Dmitrii Maganov <vonagam@gmail.com>
2023-01-09 20:12:10 -05:00
Rémi Verschelde d3fc9d9e41
Merge pull request #71051 from vonagam/consts-are-deep-start
GDScript: Begin making constants deep, not shallow or flat
2023-01-09 23:22:59 +01:00
Rémi Verschelde 509da86205
Merge pull request #69590 from anvilfolk/enums
GDScript enum fixes & refactor
2023-01-09 23:10:37 +01:00
ocean (they/them) 366ec895b1 Assorted enum and native type fixes 2023-01-09 11:08:07 -05:00
Rémi Verschelde df952a32f8
Merge pull request #71107 from vnen/gdscript-fix-nil-address-assign
GDScript: Don't use the NIL address to hold return value of functions
2023-01-09 14:22:16 +01:00
Rémi Verschelde c2f7c2d31a
Merge pull request #70655 from vonagam/fix-assert-multiline
GDScript: Fix multiline and trailing comma for assert
2023-01-09 14:19:37 +01:00
George Marques a1309f1f42
GDScript: Allow using await on calls to void functions 2023-01-09 09:55:05 -03:00
George Marques a3816434a6
GDScript: Don't use the NIL address to hold return value of functions
This prevents that the NIL address is filled with another value, which
causes problems for some instructions that read from NIL.
2023-01-09 09:20:18 -03:00
Adam Scott c45b9245ae Fix parse error using Vector{2,3,4}.INF 2023-01-08 16:14:40 -05:00
Dmitrii Maganov 71f7c8a9d3 GDScript: Fix multiline and trailing comma for assert 2023-01-08 20:18:46 +02:00
Dmitrii Maganov 5e2ac1a31e GDScript: Begin making constants deep, not shallow or flat 2023-01-08 07:29:10 +02:00
Dmitrii Maganov 532ffc30bd GDScript: Fix typing of lambda functions 2023-01-06 16:38:22 +02:00
Dmitrii Maganov a8c2f8a0e1 GDScript: Fix missing conversion for default argument values 2023-01-06 11:49:06 +02:00
Dmitrii Maganov 10e364bf43 GDScript: Fix array as default value for parameter 2023-01-06 06:25:55 +02:00
Dmitrii Maganov a1d06749f1 Unify typing of variables, constants and parameters in GDScript 2023-01-06 01:10:04 +02:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Rémi Verschelde 8203e09330
Merge pull request #70859 from vonagam/fix-preload-native-type
GDScript: Fix wrong native type for preloaded class
2023-01-03 23:22:23 +01:00
Rémi Verschelde 4e360ac612
Merge pull request #70702 from vnen/gdscript-error-on-assign-void
GDScript: Error when assigning return value of void function
2023-01-03 12:23:00 +01:00
Rémi Verschelde e4c1103af4
Merge pull request #70656 from vonagam/fix-void-returns
GDScript: Disallow return with value in void functions
2023-01-03 12:20:33 +01:00
Dmitrii Maganov 961b4ac5f5 GDScript: Fix wrong native type for preloaded class 2023-01-03 05:45:06 +02:00
George Marques 8a98110e3e
Merge pull request #62688 from cdemirer/assignments-and-types
Fixes https://github.com/godotengine/godot/issues/62650
2022-12-30 16:38:35 -03:00
George Marques 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
George Marques 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
George Marques 0c15844551
GDScript: Error when assigning return value of void function
This also makes built-in method calls empty the return value when the
method is void, to avoid keeping returning a garbage value in such case.
2022-12-30 12:08:58 -03:00
Dmitrii Maganov 056066ee95 GDScript: Fix false name conflicts for unnamed enums 2022-12-29 22:04:13 +02:00
Dmitrii Maganov 9507f65e25 GDScript: Disallow return with value in void functions 2022-12-29 03:06:13 +02:00
Dmitrii Maganov b6aa4840d8 Fix usage of Enum as constant 2022-12-28 23:04:40 +02:00
Dmitrii Maganov f67aa3e46d GDScript: Fix return type of constructor call for extending class 2022-12-27 23:02:12 +02:00
cdemirer bbb21c3fd5 Fix type adjustment skipped when value is considered both not hard and not variant 2022-12-25 17:11:30 +03:00
Rémi Verschelde ae4c025da9
Merge pull request #69991 from rune-scape/cast-type
GDScript: Fix cast producing null
2022-12-23 09:22:21 +01:00
Rémi Verschelde 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
Rémi Verschelde e1657bd2a7
Merge pull request #70440 from rune-scape/null-again
Fix GDScript analyzer null literal
2022-12-22 16:02:19 +01:00
rune-scape 3228fdb88a Fix GDScript analyzer null literal 2022-12-22 06:02:34 -05:00
ocean (they/them) d93dbab054 Add MethodInfo to signal datatype 2022-12-21 22:49:51 -05:00
Aaron Franke 6590e1fd8a
Make script annotations placed before class_name and extends 2022-12-19 22:01:29 -06:00
Adam Scott 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
Adam Scott 1bbb2b4159 Fix outer class lookup 2022-12-17 17:57:00 -05:00
Adam Scott 2fefcf7329 Fix inner class constant assignment 2022-12-17 12:03:03 -05:00
rune-scape 213c94b42f Fix enum value regression 2022-12-16 22:48:25 -05:00
Rémi Verschelde 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
rune-scape 2dfc6d5b69 GDScript: Allow out of order member resolution 2022-12-14 21:44:05 -05:00
rune-scape 7d0d6aa16f GDScript: Fix cast producing null 2022-12-12 19:57:26 -05:00
rune-scape 08449ab16e Fix String type compatibility being too permissive 2022-12-12 07:27:41 -05:00
Adam Scott 65a49bad5a Fix constant base typing in extended GDScript class 2022-12-10 13:39:45 -05:00
Rémi Verschelde 907298d673
Merge pull request #68747 from rune-scape/rune-stringname-unification
GDScript: Unify StringName and String
2022-12-09 18:06:48 +01:00
rune-scape e79be6ce07 Unify String and StringName 2022-12-05 21:46:47 -05:00
Dmitrii Maganov 97280279ee Fix incomplete shadowing of member properties by parameters 2022-12-06 00:22:56 +02:00
kobewi d1e4146462 Improve parent signature error 2022-12-01 15:16:16 +01:00
Adam Scott 69bb7e5b11 Fix singleton scene cyclic loading 2022-11-25 12:43:55 -05:00
souplamp 5bdd883dfd change RETURN_VALUE_DISCARDED GDScript warn text
changed RETURN_VALUE_DISCARDED GDscript warning text to mention how the return value of a function is discarded; update GDScript parser warning test to include new warning text.
2022-11-21 15:04:04 -06:00
Rémi Verschelde 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
Adam Scott 5704055d30 Fix cyclic references in GDScript 2.0 2022-11-18 16:41:31 -05:00
ocean (they/them) 13be0ab733 Fix ability to overload "script" variable 2022-11-17 17:21:12 -05:00
Rune bce6f1792e GDScript compiler subclass bugfixes 2022-11-13 02:29:21 -08:00
Rémi Verschelde 7eb44fa47d
Merge pull request #68125 from kleonc/range-fix-single-arg-optimized-type-mismatch
[GDScript] Fix type mismatch in optimized single arg `range`
2022-11-02 14:18:24 +01:00
kleonc c268e3a235 GDScript Fix type mismatch in optimized single arg range 2022-11-02 13:20:47 +01:00
Rafał Mikrut d7d130295e Support for checking that Projection is(not) null 2022-11-01 20:49:52 +01:00
clayjohn 0a51bb4ca5 Add STATIC_CALLED_ON_INSTANCE warning to highlight
when static functions are called directly from objects
2022-10-14 10:43:42 -07:00
clayjohn be1e9acb7c Implement RETURN_VALUE_DISCARDED warning in GDscript 2022-10-13 11:56:45 -07:00
Rémi Verschelde 62b066dbd6 Fix more MSVC C4702 (unreachable code) warnings 2022-10-07 14:43:59 +02:00
Hugo Locurcio 6afbf0bd5a
Improve dictionary printing to avoid confusion with arrays
- Add leading and trailing spaces within dictionaries, as the `{}`
  characters are hard to distinguish from `[]` on some fonts.
  This is especially helpful with empty arrays and dictionaries.
2022-10-04 20:33:40 +02:00
Hugo Locurcio 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
Aaron Franke 10a56981dc
Rename String plus_file to path_join 2022-08-29 19:38:13 -05:00
Yuri Sizov 1362bc22bd Add tests for empty/unnamed arguments to ClassDB, Variant, GDScript 2022-08-08 16:36:01 +03:00
Antonio Dell'Annunziata 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
Rémi Verschelde 33258d850c
Merge pull request #61315 from lawnjelly/variant_bucket_pools
Variant memory pools
2022-08-02 15:54:18 +02:00
Rémi Verschelde 90019676b0 Code quality: Fix header guards consistency
Adds `header_guards.sh` bash script, used in CI to validate future
changes. Can be run locally to fix invalid header guards.
2022-07-25 11:17:40 +02:00
Rémi Verschelde f0eb3ac5d3
Merge pull request #62701 from cdemirer/for-variable-conflict 2022-07-06 16:02:49 +02:00
Yuri Sizov f85bafaa11 Add grouping annotations for class properties in GDScript 2022-07-05 22:01:40 +03:00
lawnjelly b221eab426 Variant memory pools
Memory pools via PagedAllocator for Transform2D, Transform3D, Basis and AABB.
2022-07-04 12:01:46 +01:00
cdemirer dbdf0174b4 Do error when for variable conflicts with a variable in scope 2022-07-04 12:30:39 +03:00
Rémi Verschelde b730d2ee09
Merge pull request #60675 from voylin/Add-BBCode-support-for-printing-output
Adding print_rich() for printing with BBCode
2022-06-28 23:35:53 +02:00
cdemirer a0608bd891 Fix set chain bug with jump_if_shared 2022-06-28 18:45:27 +03:00
Voylin c6291bcd8a Adding print_rich for printing with BBCode 2022-06-29 00:41:29 +09:00
George Marques 1aa6e33bf5
Merge pull request #59358 from strank/debug-inner-classes 2022-06-15 10:37:18 -03:00
George Marques 67156aa4c2
Merge pull request #61666 from nathanfranke/fix-match-bind
gdscript: use correct error for unused bind match, suppress with underscore
2022-06-15 10:21:34 -03:00
George Marques 15740c37a3
Merge pull request #57151 from cdemirer/fix-match-array-dict-pattern-logic-error
Fix logic errors in match-statement Array & Dictionary patterns
2022-06-14 21:30:05 -03:00
strank 2079e19899 Extend test_compiler to also disassemble inner classes 2022-06-12 16:30:04 -04:00
Nathan Franke 3d61246bc4
use correct error for unused bind match, suppress with underscore 2022-06-03 13:28:33 -05:00
Rémi Verschelde 68bf4eb100
Merge pull request #61440 from vnen/gdscript-scene-unique-nodes
GDScript: Support `%` in shorthand for `get_node`
2022-05-31 12:36:37 +02:00
George Marques eba3e0a9fc
GDScript: Support % in shorthand for get_node
The `%` is used in scene unique nodes. Now `%` can also be used instead
of `$` for the shorthand, besides being allowed generally anywhere in
the path as the prefix for a node name.
2022-05-27 13:46:18 -03:00
Rémi Verschelde 6369e495fd
Merge pull request #61279 from Trioct/fix-typed-array-assignment 2022-05-25 17:28:22 +02:00
Trioct bcbfa641ec Fix const typed array assignment 2022-05-25 09:02:11 -05:00
George Marques 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
George Marques 1b76a9d705
GDScript: Fix lambda captures in default argument values 2022-05-23 21:38:31 -03:00
George Marques 969f1980d2
GDScript: Fix if after lambda being seen as ternary 2022-05-23 21:13:25 -03:00
George Marques 0a28b4cd94
GDScript: Do not allow standalone lambdas
They cannot be accessed in this case, so an error is shown to avoid
misleading the uses, especially in case of named lambdas.
2022-05-23 12:25:03 -03:00
Rémi Verschelde e22255edaf
Merge pull request #55201 from Scony/fix-unreachable-code-false-positive 2022-05-18 16:04:12 +02:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
reduz 8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Rémi Verschelde 9963ae3553
Merge pull request #59863 from cdemirer/fix-match-multiple-bind-single-pattern
Fix issues with multiple bind patterns in match statement
2022-05-11 14:18:02 +02:00
Rémi Verschelde 505e15c523
Merge pull request #60732 from CalebJohn/matching_signature_regression_test 2022-05-11 14:15:48 +02:00
CalebJohn 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
Nathan Franke 58fcad20ef
quote strings inside arrays and dictionaries 2022-05-03 13:37:13 -05:00
Hugo Locurcio 180e5d3028
Remove RES and REF typedefs in favor of spelled out Ref<>
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
Rémi Verschelde f626e8ef91
Merge pull request #60396 from vnen/gdscript-self-lambda 2022-04-27 13:11:24 +02:00
George Marques 01d13ab2c1
GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
PastMoments b3704e664d Fixes GDScript define nested dictionary and array as constants #50285 2022-04-19 08:57:23 -04:00
bruvzg 9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
Rémi Verschelde db8e6bd83f
Merge pull request #59885 from Jayman2000/autoload-inheritance-message 2022-04-04 23:56:20 +02:00
Jason Yundt 1cc7e7ec33 Improve autoload inheritance error message
Autoloaded scripts should always inherit from Node. When you run a
project that tries to autoload a script which doesn’t inherit from Node,
then Godot gives an error.

Before this change, the error said “Script does not inherit a Node”.
That error message is a little bit misleading. If a class inherits a
Node, then one of its superclasses has a Node. If a class inherits
_from_ Node, then one of its superclasses is Node. This change corrects
that mistake.

Fixes #59884.
2022-04-04 15:51:02 -04:00
Rémi Verschelde f8ab79e68a Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
2022-04-04 19:49:50 +02:00
cdemirer 3c5b9d1be3 Fix issues with multiple bind patterns in match statement 2022-04-04 15:47:08 +08:00
reduz 21637dfc25 Remove VARIANT_ARG* macros
* Very old macros from the time Godot was created.
* Limited arguments to 5 (then later changed to 8) in many places.
* They were replaced by C++11 Variadic Templates.
* Renamed methods that take argument pointers to have a "p" suffix. This was used in some places and not in others, so made it standard.
* Also added a dereference check for Variant*. Helped catch a couple of bugs.
2022-03-09 18:39:13 +01:00
George Marques 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
strank 7d48afa96d Add test cases for accessing parent elements from child class 2022-03-04 12:41:20 -05:00
cdemirer 3afe50c2fa Fix logic errors in match-statement Array & Dictionary Patterns 2022-03-02 19:05:18 +08:00
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 b013c0d544
GDScript: Allow tests to run on release builds
- Fix compilation issues by disabling warnings on release builds. This
  also strips warnings from expected result before the comparison to
  avoid false mismatches.
- Add a `#debug-only` flag to tests. Must be the first line of the test
  script. Those won't run with release builds. Can be used for test
  cases that rely on checks only available on debug builds.
2022-02-03 13:32:33 -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
Rémi Verschelde e1706be25d
Merge pull request #57052 from KoBeWi/nosort 2022-01-23 00:27:01 +01:00
Rémi Verschelde 182a36db47
Merge pull request #55214 from Scony/fix-gdscript-crash-2
Fix GDScript parser crash on 'dollar mixed with assignment' expression
2022-01-22 20:30:54 +01:00
kobewi f056cb8ebc Don't sort printed Dictionary 2022-01-22 13:45:02 +01:00
strank 960a26f6c0 GDScript: Fix parsing default parameter values from function calls 2022-01-13 19:28:39 -05:00
bruvzg c69e0d16bc
Fix multiple missing UTF-8 decoding. 2022-01-06 14:35:22 +02: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
luz paz a124f1effe Fix various typos
Found via ` codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,expct,fave,findn,gird,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint,varn`
Update editor/import/resource_importer_layered_texture.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update doc/classes/TileSetScenesCollectionSource.xml

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/gui/graph_edit.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/resources/animation.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/resources/animation.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/resources/animation.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/gui/rich_text_label.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Revert previously committed change
2022-01-02 01:03:58 -05:00
Yuri Roubinsky 566895732c Fix shadowed global identifier warning duplication 2021-12-13 11:54:23 +03:00
Nathan Franke 49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
Pawel Lampe 1a15a3adf6 Fix GDScript parser crash on 'dollar mixed with assignment' expression
fixes #53696
2021-11-21 21:18:46 +01:00
Pawel Lampe 86c0e38e8f Fix 'unreachable-code' false-positive, fixes #55154 2021-11-21 15:53:21 +01:00
Yuri Roubinsky 3396b25489 Allow using built-in names for variables, push warnings instead 2021-11-13 21:47:24 +03:00
Max Hilbrunner 626ca50676 Improve GDScript indentation error message 2021-10-28 13:01:53 +02:00
reduz d03b7fbe09 Refactored Node3D rotation modes
* Made the Basis euler orders indexed via enum.
* Node3D has a new rotation_order property to choose Euler rotation order.
* Node3D has also a rotation_mode property to choose between Euler, Quaternion and Basis

Exposing these modes as well as the order makes Godot a lot friendlier for animators, which can choose the best way to interpolate rotations.
The new *Basis* mode makes the (exposed) transform property obsolete, so it was removed (can still be accessed by code of course).
2021-10-25 14:34:00 -03:00
Rémi Verschelde 4387f9645b
Merge pull request #52940 from groud/toast_notification 2021-10-19 09:57:13 +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 056a54db7b
GDScript: Properly return value with await on non-coroutine
If the keyword `await` is used without a coroutine, it should still
return the value synchronally.
2021-10-14 19:58:10 -03:00
Rémi Verschelde 472ff40f71
Merge pull request #53807 from vnen/dont-share-arrays-and-dicts 2021-10-14 20:42:22 +02:00
George Marques 4c14051b3f
Zero Dictionary and Array variants when changing type with reset
So they don't reference to the old values anymore and instead refer to
a new value.
2021-10-14 11:22:17 -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
Gilles Roudière 0587e5e018 Implement toast notifications in the editor 2021-10-14 13:30:54 +02:00