Commit Graph

488 Commits

Author SHA1 Message Date
Rémi Verschelde f2918c73cf
Revert "GDScript: Fix common mismatched external parser errors"
This reverts commit c75225ffb2.

This caused a crashing regression for multiple users:
https://github.com/godotengine/godot/pull/94617#issuecomment-2247868580
2024-07-25 09:20:23 +02:00
Rémi Verschelde e91725f490
Merge pull request #94617 from rune-scape/fix-mismatched-parsers
GDScript: Fix common mismatched external parser errors
2024-07-24 09:59:19 +02:00
rune-scape c75225ffb2 GDScript: Fix common mismatched external parser errors 2024-07-23 12:25:23 -07:00
Danil Alexeev 638148a184
GDScript: Fix false positive cases of `ENUM_VARIABLE_WITHOUT_DEFAULT` 2024-07-22 21:45:01 +03:00
baptr 810fcc7431 Fix gdscript analyzer error when instantiating EditorPlugins.
Editor code is not instantiable outside of the editor
(1d14c054a1/core/object/class_db.cpp (L369)).
This is fine for editor plugins and the like, but the GDScript analyzer
balks at it, causing F5 runs to fail: #73525.

Instead, we really just want to know if the type is abstract - so add
a new ClassDB method to check that and nothing else.

Update core/object/class_db.cpp

Apply code review comments

Co-Authored-By: Bryce <1522777+baptr@users.noreply.github.com>
2024-07-10 10:24:57 +02:00
Danil Alexeev d15ed0bcbb
GDScript: Fix false positive `CONFUSABLE_CAPTURE_REASSIGNMENT` warnings 2024-06-28 16:41:32 +03:00
Danil Alexeev 68898dbcc9
GDScript: Add `CONFUSABLE_CAPTURE_REASSIGNMENT` warning 2024-06-28 11:12:01 +03:00
Rémi Verschelde 0364443d12
Merge pull request #93346 from RandomShaper/gds_cyc_alt
GDScript: Enhance handling of cyclic dependencies
2024-06-26 18:15:16 +02:00
Pedro J. Estébanez c1391489e3 GDScript: Enhance handling of cyclic dependencies 2024-06-26 17:44:32 +02:00
Hilderin e18db6fe60 Fix editor crash when invalid global class script path 2024-06-25 08:13:04 -04:00
Rémi Verschelde ce82984b5c
Merge pull request #92544 from dalexeev/gds-fix-const-non-metatype-subscript
GDScript: Fix subscript resolution on constant non-metatype GDScript base
2024-05-30 22:38:36 +02:00
Danil Alexeev 3fd30ed4ff
GDScript: Do not produce `INFERRED_DECLARATION` on type import 2024-05-30 19:30:07 +03:00
Danil Alexeev 18d8838051
GDScript: Fix subscript resolution on constant non-metatype GDScript base 2024-05-30 17:37:05 +03:00
Danil Alexeev 4b692959de
GDScript: Fix lambdas capturing non-local variables 2024-05-22 10:07:31 +03:00
Danil Alexeev 7dd801c580
GDScript: Fix `STANDALONE_EXPRESSION` warning for `preload()` 2024-05-17 10:33:01 +03:00
Rémi Verschelde bdefe53992
Merge pull request #91909 from KoBeWi/have_fun_reviewing_this
Use Core/Scene stringnames consistently
2024-05-14 12:07:03 +02:00
kobewi 413c11357d Use Core/Scene stringnames consistently 2024-05-13 23:41:07 +02:00
Rémi Verschelde 0a67ee52d1
Revert "GDScript: Implement get_dependencies()"
This reverts commit dc73440f89.

This commit in some form is needed to fix handling of dependencies on
export, but as it's also used for import, it's exposing some pre-existing
issues which we need to solve first.

So reverting for now to give ourselves time to iron this out for a future
Godot release.

Fixes #91726.
2024-05-13 16:59:43 +02:00
kobewi a262d2d881 Add shorthand for using singleton string names 2024-05-11 18:53:08 +02:00
A Thousand Ships 955d5affa8
Reduce and prevent unnecessary random-access to `List`
Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when
accessing a single element)

* Removed subscript operator, in favor of a more explicit `get`
* Added conversion from `Iterator` to `ConstIterator`
* Remade existing operations into other solutions when applicable
2024-05-04 16:08:55 +02:00
K. S. Ernest (iFire) Lee f9b488508c
Add PackedVector4Array Variant type
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2024-05-03 00:58:27 +02:00
Danil Alexeev 8122a27eac
GDScript: Fix access non-static members in static context 2024-05-01 19:55:40 +03:00
Rémi Verschelde c4733e8003
Merge pull request #90860 from vnen/gdscript-get-dependencies
GDScript: Implement `get_dependencies()`
2024-04-29 12:30:12 +02:00
Rémi Verschelde 296758a8f8
Merge pull request #90552 from vnen/gdscript-constructor-callable-release
GDScript: Assume constructor to be accessible from class
2024-04-29 12:30:08 +02:00
George Marques 8b7fc225f0
GDScript: Resolve types from autoload scenes
When the autoload is a scene, it now extracts the script from it and
use it to further infer nested types.
2024-04-26 10:46:19 -03:00
Rémi Verschelde e8eca0b3f0
Merge pull request #90601 from rune-scape/rune-gdscript-dependant-parser-ref-errors
GDScript: Fix out of date errors in depended scripts
2024-04-22 22:18:15 +02:00
rune-scape 6b88c86cec GDScript: invalidate GDScriptParserRef when reloading 2024-04-18 14:05:58 -07:00
George Marques dc73440f89
GDScript: Implement get_dependencies()
The parser and analyzer now track the dependencies of the script and
return the list when the resource loader ask for them.

What is considered a dependency:

- Any `preload()` call.
- The base script this one extends.
- Any identifier, including types, that refers to global scripts.
- Any autoload singleton reference.
2024-04-18 11:54:37 -03:00
Rémi Verschelde 978d206f34
Merge pull request #90794 from vnen/gdscript-no-unused-constant-warning-with-underscore
GDScript: Suppress unused constant warning with underscore
2024-04-18 15:17:13 +02:00
George Marques a3b3a20ac0
GDScript: Suppress unused constant warning with underscore
The warning message mentions that local constants prefixed with `_` does
not generate the warning. This commit actually implements this warning
suppression.
2024-04-18 09:58:23 -03:00
George Marques f9048fcd7d
GDScript: Warn when enum variable has no default
The default will always be set to `0`, so if it's not a valid value in
the enum, the warning is shown.
2024-04-16 11:46:59 -03:00
George Marques 030995c10d
GDScript: Allow casting enum to int
An enum value is always an integer so the cast is valid. The code here
now consider this case to avoid giving an error message.
2024-04-12 11:49:21 -03:00
George Marques e761982979
GDScript: Assume constructor to be accessible from class
Since the constructor is accessed directly from the class, even if not
marked `static`, it can be retrieved as a Callable without an instance.
2024-04-11 20:28:46 -03:00
Rémi Verschelde 67076c167d
Merge pull request #90448 from vnen/gdscript-infer-string-format
GDScript: Infer type with string format operator
2024-04-10 17:49:49 +02:00
Rémi Verschelde 8611fd8400
Merge pull request #90442 from vnen/gdscript-dont-warn-using-default-builtin
GDScript: Don't warn on unassigned for builtin-typed variables
2024-04-10 17:49:44 +02:00
George Marques 877802e252
GDScript: Don't warn on unassigned for builtin-typed variables
If the type of a variable is a built-in Variant type, then it will
automatically be assigned a default value based on the type. This means
that the explicit initialization may be unnecessary. Thus this commit
removes the warning in such case.

This also changes the meaning of the unassigned warning to happen when
the variable is used before being assigned, not when it has zero
assignments.
2024-04-10 11:59:57 -03:00
George Marques 4bdba718c5
GDScript: Infer type with string format operator
If the left value type is known to be String, assume the format operator
(`%`) will return a string, since it works with any type in the right
hand side. This is also used by type inference even if the right hand
type is unknown at compile time.
2024-04-10 11:49:30 -03:00
Rémi Verschelde f8ca571efe
Merge pull request #84043 from dalexeev/gds-fix-unsafe-cast-warning
GDScript: Fix `UNSAFE_CAST` warning
2024-04-09 22:24:55 +02:00
Jamie Hill-Daniel 164b34a734 Don't pass `self` when calling a static function from a non-static context 2024-04-04 21:15:17 +00:00
Danil Alexeev ef1909fca3
GDScript: Fix `@warning_ignore` annotation issues 2024-03-12 19:00:06 +03:00
20kdc 24181d1055
GDScript: Adjust STATIC_CALLED_ON_INSTANCE warning to not default to the native type, and to not trigger on self-calls
Not defaulting to the native type rationale:

Defaulting to the native type is less than useful, as:

* There are very few native types that are extensible and have static methods.
* Defaulting to the native type does not account for a method being script-defined.

While the "real fix" would be to carefully track the source of the method, the get_function_signature method is already complicated enough.

This will at least ensure the resulting code should always be valid.

Not triggering on self-calls rationale:

Found in PR comment https://github.com/godotengine/godot/pull/85918#issuecomment-1935864459

```
static func example():
	pass

func example2():
	example() # self-call on static function
```

Disabling this warning on self-calls is:

* Consistent with other languages
* Important for anonymous classes (where the output code is unusable)
2024-03-01 17:14:59 +03:00
Danil Alexeev 8ffc50ee8c
GDScript: Canonicalize script path in FQCN 2024-02-26 10:46:24 +03:00
Rémi Verschelde ee5ace10b7
Merge pull request #85501 from /remove-packed-scene-cache 2024-02-25 11:49:27 +01:00
Danil Alexeev a2e3e31e80
GDScript: Fix extension comparison for exported scripts 2024-02-15 17:53:24 +03:00
Rémi Verschelde 9572cf5ab2
Merge pull request #86823 from dalexeev/gds-utility-func-as-callable
GDScript: Allow utility functions to be used as `Callable`
2024-01-30 17:47:50 +01:00
Yuri Sizov 72756133e0 Merge pull request #85224 from HolonProduction/identifier-type-prefer-annotated
Prefer identifiers annotated type if assigned type is incompatible to it
2024-01-24 14:07:52 +01:00
Rémi Verschelde b5dcb5f58a
Merge pull request #85215 from HolonProduction/type-from-property-class-name
Handle global classes when resolving type from `PropertyInfo`
2024-01-18 09:33:22 +01:00
HolonProduction 0203b3c310 Prefer identifiers annotated type if assigned type is incompatible to it 2024-01-17 22:32:00 +01:00
HolonProduction 4ab985d138 Handle global classes when resolving type from `PropertyInfo` 2024-01-17 21:39:51 +01:00
Danil Alexeev b31acb0cd5
GDScript: Allow utility functions to be used as `Callable` 2024-01-05 21:16:53 +03:00