Commit Graph

2920 Commits

Author SHA1 Message Date
Rémi Verschelde 11ee6fcef0
Merge pull request #68311 from RobertMasek/fix-go-to-definition
Fix functionality of Go To Definition for properties set/get
2023-06-18 16:26:42 +02:00
Danil Alexeev aebbbda080
GDScript: Fix some bugs with static variables and functions 2023-06-16 22:52:11 +03: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 3b4504afea
Merge pull request #75944 from akien-mga/style-modules-includes
Style: Harmonize header includes in modules
2023-06-15 15:26:14 +02:00
Rémi Verschelde 12e8bc558d
Merge pull request #73203 from dalexeev/gds-fix-num-literal
GDScript: Fix repeated `_` are allowed after decimal point
2023-06-15 15:26:09 +02:00
Rindbee cbce374f68 Returns null and does not cache when the source code of the script fails to load
This usually means that an `ERR_FILE*` error occurred.

Previously, using `GDScriptCache::get_full_script()` would ignore errors during loading.
Now, all errors are not ignored.

Judging in which period the error occurred, it can be judged based on the return value:
1. null + err : Error during script loading (load_source_code()).
2. script + err: Error during script parsing.
2023-06-15 21:06:10 +08: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
Danil Alexeev bf8f996212
GDScript: Fix conflict between property and group names 2023-06-15 08:36:10 +03:00
rune-scape fcdd926881 GDScript: Strings and StringNames match 2023-06-14 19:24:28 -07:00
Danil Alexeev fba8cbe6db
GDScript: Fix repeated `_` are allowed after decimal point 2023-06-14 21:47:12 +03:00
Rémi Verschelde 72b8d397d0
GDScript: Further restrict test error output for C++ errors
MSVC and GCC/Clang also have different function names...
2023-06-14 13:28:52 +02:00
Rémi Verschelde c40adf027d
GDScript: Only include script file path in test error output
Errors originating in C++ files cause unnecessary diffs whenever the engine is updated
(line number changes, etc.) and would cause CI failures due to different formatting
of the file path on Windows (backslashes, worked around here anyway) and when using
SCU builds (`../scu` insert).
2023-06-14 10:54:49 +02:00
Rémi Verschelde 5145098e6e
Merge pull request #78138 from KoBeWi/are_we_clear
Clear SelfList when destroying GDScriptLanguage
2023-06-14 09:25:34 +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
Danil Alexeev ddd9aa11b3
Clarify `@rpc` annotation arguments docs 2023-06-13 21:33:48 +03:00
Rémi Verschelde eb86dabee0
Merge pull request #77151 from dalexeev/gds-fix-call-static-from-non-static
GDScript: Fix calling static func from non-static is allowed
2023-06-13 18:54:19 +02:00
kobewi c646f7df70 Clear SelfList when destroying GDScriptLanguage 2023-06-12 16:04:26 +02:00
Rémi Verschelde 577ab3c565
Merge pull request #75746 from ajreckof/order_autocomplete
Sort code autocompletion with rules
2023-06-08 18:14:31 +02:00
Danil Alexeev 049a49cac0
GDScript: Fix doc comment parsing (newlines and spaces) 2023-06-05 16:00:46 +03:00
Danil Alexeev f3bf75fbb4
GDScript: Reset local variables on exit from block 2023-06-02 13:20:19 +03:00
Ninni Pipping 5e3c625e24 Add more info on the nature of NAN 2023-05-30 15:38:10 +02:00
Yuri Sizov 490a76edc8
Merge pull request #76526 from MewPurPur/improve-docs-top-sections-CORE
Overhaul the top sections of the class reference (Core classes)
2023-05-29 17:08:40 +02:00
Haoyu Qiu 3e88c4cd5c Fix extraction of chained tr() calls 2023-05-27 10:38:37 +08:00
ajreckof 006e899bb3 sort code completions with rules
Fixups

Add levenshtein distance for comparisons, remove kind sort order, try to improve as many different use cases as possible

Trying again to improve code completion

Sort code autocompletion options by similarity based on input

To make it really brief, uses a combination `String.similiary`, the category system introduced in a previous PR, and some filtering to yield more predictable results, instead of scattering every completion option at seemingly random.

It also gives much higher priority to strings that contain the base in full, closer to the beginning or are perfect matches.

Also moves CodeCompletionOptionCompare to code_edit.cpp

Co-Authored-By: Micky <66727710+Mickeon@users.noreply.github.com>
Co-Authored-By: Eric M <41730826+EricEzaM@users.noreply.github.com>
2023-05-23 05:12:34 +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
Rémi Verschelde 06d337af80
Merge pull request #75943 from adamscott/fix-missing-script-type-nullptr-check
Add missing `script_type` `nullptr` check
2023-05-22 13:48:32 +02:00
VolTer 04562662d3 Overhaul the top sections of the class reference (Core classes) 2023-05-19 07:04:48 +02:00
Max Hilbrunner ad21fb0f92 Docs: Point to @GDScript in GDscript (script impl) 2023-05-17 13:47:33 +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
smix8 a6ac305f96 Rework Navigation Avoidance
Rework Navigation Avoidance.
2023-05-10 05:01:58 +02:00
Rémi Verschelde 1d87b36760
Merge pull request #76824 from Calinou/doc-export-pck-binary-resource-conversion
Document caveats related to exported project binary resource conversion
2023-05-09 19:28:46 +02:00
Rémi Verschelde c2ba89d9d1
Merge pull request #76790 from achernik/master
LSP: don't send empty completion command
2023-05-09 19:28:42 +02:00
Rémi Verschelde 10ed1d87df
Merge pull request #76490 from dsnopek/dump-gdscript-docs
Dump API docs from inline GDScript comments using --doctool --gdscript-docs PATH
2023-05-09 19:28:30 +02:00
David Snopek a64137d5dd Dump API docs from inline GDScript comments using --doctool --gdscript-docs PATH 2023-05-08 11:00:29 -05:00
Hugo Locurcio febc674f48
Document caveats related to exported project binary resource conversion 2023-05-08 07:02:00 +02:00
Александр Черник 5715d3eb59 LSP: don't send empty completion command 2023-05-06 20:56:15 +01:00
Max Hilbrunner 921d231ad6
Merge pull request #76664 from Xenoparrot/simple-typos 2023-05-06 15:41:55 +02:00
Clay John 610877e326
Merge pull request #72288 from MewPurPur/use-string-repeat
Use `String.repeat()` to optimize several String methods
2023-05-05 09:56:48 -07:00
Max Hilbrunner ce75c46331
Merge pull request #76650 from Koyper/gdscript_range_docs 2023-05-05 17:09:56 +02:00
UltraBIF 8106d33d0f Fixed various typos across the docs 2023-05-02 18:24:32 -04:00
Koyper bcce315a9a Update @GDScript.xml range docs to iterate backwards. 2023-05-01 11:03:48 -05:00
VolTer 6b84e258d2 Use String.repeat() in more places 2023-05-01 02:27:46 +02: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 0762f20410
Merge pull request #75732 from vonagam/fix-duplicate-condition
GDScript: Fix unnecessary duplication of pointed out lines
2023-04-28 18:45:25 +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
Rémi Verschelde 7780926b25
GDScript: Fix template_debug compilation with TOOLS/DEBUG macro mismatch 2023-04-28 11:09:12 +02: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
Rémi Verschelde 352ebe9725
Merge pull request #76483 from vnen/gdscript-dont-fail-returning-freed-object
GDScript: Don't fail when freed object is return
2023-04-27 08:47:04 +02:00
Rémi Verschelde 58439ac22c
Merge pull request #74053 from vnen/gdscript-fix-disassembler-lambda-crash
GDScript: Fix wrong increment for disassembly of lambda
2023-04-27 08:46:40 +02:00
Rémi Verschelde 35f6a1387c
Merge pull request #76488 from YuriSizov/docs-validate-code-params
Validate code tags in documentation for potential params
2023-04-27 08:20:42 +02:00
Rémi Verschelde 80568be36f
Merge pull request #76481 from vnen/gdscript-test-gen-default-path
GDScript: Use default path in test generator if not provided
2023-04-27 08:19:54 +02:00
Yuri Sizov 391eccca76 Validate code tags in documentation for potential params
Adds a check to make_rst to look for matches
between the text inside of the [code][/code] tag
and known param identifiers.
Fixes most of what was revealed.
2023-04-26 21:36:04 +02:00
Yuri Sizov 26fb911f79
Merge pull request #72095 from anvilfolk/gd-docs
Improve GDScript documentation generation & behavior
2023-04-26 16:54:25 +02:00
Ninni Pipping f68beeb7fa Improvements to GDScript identifier tokenization 2023-04-26 16:29:04 +02:00
George Marques 221deb1cc1
GDScript: Use default path in test generator if not provided
Since it's almost always used with the same path, assume it is running
from the Godot source root.
2023-04-26 11:12:47 -03:00
George Marques abbdf80643
GDScript: Don't fail when freed object is return
This is check is a bit too eager. The user should be able to handle the
return value even if it's a freed object.
2023-04-26 10:57:22 -03:00
Rémi Verschelde 45cd5dcad3
Merge pull request #75885 from AThousandShips/compound_fix
[GDScript] Fix incorrect compound assignment
2023-04-25 16:17:02 +02:00
Rémi Verschelde a98997bb45
Merge pull request #76404 from sodaJar/gdrep
Fix wrong file name on function call error
2023-04-25 10:00:19 +02:00
Rémi Verschelde 15d952147c
Merge pull request #74101 from RandomShaper/fix_gds_obj_temps
Fix edge cases of object lifetime when signals involved
2023-04-25 09:58:17 +02:00
Rémi Verschelde d45c6fd591
Merge pull request #76095 from adamscott/fix-rename-lsp-variables
[LSP] Fix GDScript inner method variable rename
2023-04-24 16:44:44 +02:00
Rémi Verschelde 54b0e8123e
Merge pull request #75605 from anvilfolk/type-base
Make GDScript type not found errors more informative.
2023-04-24 16:43:32 +02:00
sodaJar 464a299d2e Fix wrong file on function call error 2023-04-24 15:30:51 +02:00
Adam Scott 10fe6f14bb Fix GDScript LSP variable rename 2023-04-22 14:35:34 -04:00
ocean (they/them) 6783ff69c0 Improve and fix GDScript documentation generation & behavior
Removes documentation generation (docgen) from the GDScript compiler to
its own file. Adds support for GDScript enums and signal parameters and
quite a few other assorted fixes and improvements.
2023-04-21 10:17:30 -04:00
Rémi Verschelde bf62af334b
Merge pull request #76286 from MystMagus/gdscript-mixed-tabs-and-spaces-fix
Fix for mixed tabs and spaces in gdscript
2023-04-20 18:08:47 +02:00
MistMage fecbc12d17 Fix for mixed tabs and spaces in gdscript 2023-04-20 12:08:23 +02:00
Danil Alexeev dbc3c82043
GDScript: Add some checks for `@tool` and `@icon` 2023-04-20 07:44:10 +03:00
Yuri Sizov f3033da97d
Merge pull request #76170 from HolonProduction/string-highlight
Fix multi-line string highlighting with single quotes.
2023-04-18 18:01:02 +02:00
Yuri Sizov 9882af4880
Merge pull request #76197 from dalexeev/fix-error-macro-misuses
Fix misuses of error macros
2023-04-18 16:11:37 +02:00
Yuri Sizov e31d391d56
Merge pull request #76090 from adamscott/fix-typo-lsp-parse-func-parameters
[LSP] Fix typo in parse function parameters
2023-04-18 15:57:08 +02:00
RedMser 2330ffb5a1 Add GDScript template to RichTextEffect 2023-04-18 14:02:04 +02:00
Danil Alexeev 36bedd341a
Fix misuses of error macros 2023-04-18 10:20:48 +03:00
Yuri Sizov 6596a6c1b5
Merge pull request #72979 from dalexeev/gds-annotation-parsing
GDScript: Fix and improve annotation parsing
2023-04-17 17:14:58 +02:00
Yuri Sizov d220680bd0
Merge pull request #62830 from ajreckof/access-identifier-keywords
fix access to identifiers that are reserved keywords
2023-04-17 17:12:10 +02:00
HolonProduction bdb7045e2c Fix multi-line string highlighting with single quotes. 2023-04-17 15:58:39 +02:00
Adam Scott 879791e305 Fix typo when parsing LSP function parameters 2023-04-15 09:05:53 -04:00
ajreckof ab9f60dd1a fix access to identifiers that are reserved keywords 2023-04-14 20:37:24 +02:00
Danil Alexeev 5038a336be
GDScript: Fix and improve annotation parsing 2023-04-14 21:28:46 +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
Yuri Sizov afca0b8fdd
Merge pull request #75879 from dalexeev/gds-fix-extends-crash
GDScript: Add missing member type check when resolving `extends`
2023-04-14 13:21:54 +02:00
Ninni Pipping e5365da03c [GDScript] Fix incorrect compound assignment
Reverts in-place compound assignments

Added test to ensure correctness
2023-04-14 11:28:44 +02:00
Adam Scott 1236302388 Add missing `script_type` `nullptr` check
Co-authored-by: Fabio Alessandrelli <fabio.alessandrelli@gmail.com>
2023-04-11 12:36:28 -04:00
Pedro J. Estébanez 2f4168daeb Fix edge cases of object lifetime when signals involved 2023-04-11 17:27:39 +02:00
George Marques 59b8c70007 GDScript: Don't use pool for reference types
Since they need to be properly initialized and finalized to adjust the
reference counter.
2023-04-11 16:46:31 +02:00
Fabio Alessandrelli 4ab0b38940
Merge pull request #75850 from rsubtil/bugfix-lsp_dap_connection_poll
Poll LSP/DAP clients for connection status updates
2023-04-11 10:19:24 +02:00
Danil Alexeev 66279b98b6
GDScript: Add missing member type check when resolving `extends` 2023-04-10 17:16:07 +03:00
VolTer f832eb92e4 Fix mistakes in documentation and GDScript errors 2023-04-10 10:00:09 +02:00
Ricardo Subtil 4be4eeea3a Poll LSP/DAP clients for connection status updates 2023-04-09 12:36:01 +01: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 5dc717c5fd GDScript: Fix unnecessary duplication of pointed out lines 2023-04-06 06:12:32 +03:00
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
Araraura e1c0df7048
Fix typo and slightly reword in @GDScript.xml
Fix "the every following property" to "then every following property" and change "is added" to "will be added".
2023-03-31 20:30:29 +00:00
Dmitrii Maganov 8655d979a1 GDScript: Allow elements of a parent class in a typed array literal 2023-03-28 13:47:24 +03:00
AleryBerry 0550f3682b GDScript: Fix error message for Lua-style dictionary 2023-03-20 21:45:06 +00:00
Yuri Sizov a008a06fcb
Merge pull request #72056 from resistor/master
[GDScript] Perform update-and-assign operations in place when possible.
2023-03-20 19:16:30 +01: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
Yuri Sizov a5f34744a2
Merge pull request #74842 from vonagam/fix-builtin-shadow
GDScript: Fix missing warning for shadowing of built-in types
2023-03-20 19:10:13 +01:00
Hugo Locurcio 4e4555bea5
Improve Color8 documentation
This documents in which situations Color8 is most suited and its
precision limitations.
2023-03-19 17:42:15 +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 e289a4ab2c GDScript: Fix autocomplete inside a block with a type test condition 2023-03-09 23:53:27 +02:00
Yuri Sizov 496bd94c21 Prevent cache corruption when saving resources in the editor 2023-03-08 19:46:55 +01:00
Rémi Verschelde 9eaaeef76d
Merge pull request #73410 from MewPurPur/Fixin-error-spam-2-Electric-Boogaloo
Fix error spam when naming a func at the end of the script
2023-03-08 08:54:57 +01:00
VolTer 07dd627728 Fix error spam when naming a func at the end of the script 2023-03-07 23:42:40 +01:00
Rémi Verschelde 2a5fc1fe6c
Merge pull request #74306 from dalexeev/gds-var-colon-style
Fix GDScript code style regarding colon
2023-03-06 10:49:11 +01:00
Danil Alexeev ea5fd3d732
Fix GDScript code style regarding colon 2023-03-05 17:03:20 +03:00
Rémi Verschelde a0134f7fbc
Merge pull request #74147 from vonagam/fix-call-await-check-in-compiler
GDScript: Fix checking if a call is awaited in compiler
2023-03-05 13:23:27 +01:00
Rémi Verschelde 326c0f324a
Merge pull request #74184 from MewPurPur/fix-number-highlighting-in-wrong-places
Make GDScript Number highlighting stricter
2023-03-03 11:07:04 +01:00
VolTer 952703d921 Make GDScript number highlighting stricter 2023-03-01 21:27:32 +01:00
Dmitrii Maganov 55a2ad25bf GDScript: Fix checking if a call is awaited in compiler 2023-03-01 09:31:35 +02:00
Rémi Verschelde 1c1524a651
Bump version to 4.1-dev
Can't stop, won't stop, they said, huh?
2023-03-01 01:44:37 +01:00
Rémi Verschelde 491ded1898
Minor typo and docs URL fixes 2023-02-28 13:38:01 +01:00
George Marques 5b49382d38
GDScript: Fix wrong increment for disassembly of lambda 2023-02-27 11:19:22 -03:00
voidedWarranties bd5ab9f9b4 Remove unused `ScriptLanguage` methods 2023-02-26 22:30:56 -08: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 1bd0b296e1
Merge pull request #73964 from vonagam/fix-coroutine-compiler-type
GDScript: Fix address type for coroutine results
2023-02-26 16:00:17 +01:00
Rémi Verschelde 92d47f84fe
Merge pull request #73957 from vonagam/fix-binary-op-safety
GDScript: Fix wrong unsafety mark for binary operator
2023-02-26 15:59:54 +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
Dmitrii Maganov 4efaf15605 GDScript: Fix address type for coroutine results 2023-02-26 08:30:46 +02:00
Dmitrii Maganov 638aa4f811 GDScript: Fix wrong unsafety mark for binary operator 2023-02-26 01:35:53 +02: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
Danil Alexeev a98a0f5d34
Document `@GDScript.is_instance_of` method 2023-02-22 17:06:55 +03: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
Rémi Verschelde 49c1902a04
Merge pull request #73689 from vnen/gdscript-fix-inheritance-native-class
GDScript: Fix setting native type with script inheritance
2023-02-21 23:35:18 +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
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
Rémi Verschelde 31726fa945
Merge pull request #73680 from vnen/gdscript-div-by-zero-crash-fix
GDScript: Avoid validated division operation to test for zero
2023-02-21 21:19:15 +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 d076c76551
GDScript: Fix setting native type with script inheritance
Sometimes the inheritance tree is compiled out of order and the base
don't have yet a native type set. This is now changed to not rely on the
base script but use the native type set in the datatype, which is
already resolved by the analyzer.
2023-02-21 14:09:10 -03:00
George Marques 0866e6af2d
GDScript: Avoid validated division operation to test for zero
The validated operations for integer division and modulo do not check
for division by zero. This avoids validated operation in these cases to
make sure the check is performed and avoid crashing the engine.
2023-02-21 11:12:45 -03:00
George Marques 91b93465d5
GDScript: Fix crash when autoload script can't be found 2023-02-21 10:45:24 -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
George Marques c9e49c487d
GDScript: Limit recursion depth for completion functions
Avoid crashing if the completion gets stuck in infinite recursion while
trying to guess the expression type.
2023-02-20 14:55:13 -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 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
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
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
Yuri Sizov 78cd5d813b
Merge pull request #73501 from anvilfolk/oopsiedaisy
Fix inability to assign null regression
2023-02-18 04:38:47 +03:00
Yuri Sizov 24344de4f5
Merge pull request #73448 from RandomShaper/fix_sticky_stack
Avoid GDScript bookkeeping from referencing objects longer than necessary
2023-02-17 23:22:20 +03:00
Pedro J. Estébanez 5e9400fa50 Avoid GDScript bookkeeping from referencing objects longer than necessary 2023-02-17 18:59:17 +01: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 6212da66e8
Merge pull request #72867 from vnen/gdscript-limit-call-depth
GDScript: Add limit to call depth
2023-02-17 17:00:46 +03: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
Rémi Verschelde a845553898
Merge pull request #73364 from anvilfolk/fix-freed
Fix crash by freed object assign to typed variable
2023-02-17 00:31:19 +01:00
ocean (they/them) c45970739e Fix crash by freed object assign to typed variable 2023-02-16 15:17:46 -05:00
Dmitrii Maganov 5972ba17a4 GDScript: Fix infer on read-only property 2023-02-16 15:50:17 +02: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
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
Micky 436bbfebe2 Tweak `@GlobalScope` & `GDScript`'s documentation 2023-02-14 13:26:18 +01: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 d405392847
Revert "Fixed the jumping to function definition using 'Ctrl+LMB'."
This reverts commit 7eb6367d5c.

Fixes #73058.
Fixes #73167.

This caused regressions, we'll retry with fixes for 4.1.
2023-02-13 17:58:59 +01:00
pkowal be4d8a7b2e
Improve GDScript error for method call on null/previously freed instance
Fixes #53878.
2023-02-12 21:52:05 +01:00
Rémi Verschelde cb2e73d578
Merge pull request #73033 from akien-mga/gdscript-fix-gd4-renames-build
Clean up ProjectConverter3To4 architecture, move renames map to separate file
2023-02-11 22:05:38 +01:00
Rémi Verschelde 532381562e
Merge pull request #72654 from RandomShaper/ptrcall_ret_raw_obj
Avoid losing references to objects in the native-scripting boundary
2023-02-11 15:35:01 +01: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
Danil Alexeev 220898a69f
GDScript: Remove `treat_warnings_as_errors` project setting 2023-02-10 10:16:33 +03: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
Rémi Verschelde 6fca54a81b
Merge pull request #72975 from vnen/gdscript-no-ascii-spoof-check
GDScript: Be more lenient with identifiers
2023-02-09 16:12:09 +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
Rémi Verschelde b12bf7ff02
Merge pull request #69550 from Rindbee/fix-script-editor-not-reload-via-lsp
Fix internal editor not updating when using external editor via LSP
2023-02-09 14:01:33 +01:00
Dmitrii Maganov cedc5fa823 GDScript: Fix error about enum typed arrays 2023-02-09 00:31:40 +02:00
kobewi e822182bb7 Fix null message in assert() 2023-02-08 20:19:24 +01:00
George Marques 34f0a2ca46
GDScript: Add limit to call depth
The hard limit is set at 2048 depth which seems sensible between
legitimate recursive calls while still avoiding a crash because of a
stack overflow in most of the cases.

Note that it is still possible to reach the stack limit and get an
overflow before reaching a call depth. This is intended as a half-way
measure to stop crashing in most cases, since there's no reliable nor
portable way to check the amount of stack memory left.
2023-02-07 17:09:40 -03:00
Rémi Verschelde bd267c911b
Merge pull request #72493 from dalexeev/gds-export-flags
GDScript: Improve validation and documentation of `@export_flags`
2023-02-07 19:38:21 +01:00
Rémi Verschelde 3f95b39cb3
Merge pull request #72789 from Vilcrow/fix-jump-to-definition
Fixed the jumping to function definition using 'Ctrl+LMB'.
2023-02-07 19:37:50 +01:00
Danil Alexeev c8e3d8b5d5
GDScript: Improve validation and documentation of `@export_flags` 2023-02-07 19:32:08 +03: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 54770ba9c5
GDScript: Fix invalid character error message 2023-02-07 10:56:10 +03:00
S.V.I. Vilcrow 7eb6367d5c Fixed the jumping to function definition using 'Ctrl+LMB'. 2023-02-07 05:29:48 +03: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
Yuri Sizov 9d16250353
Merge pull request #70002 from poohcom1/fix/static-subscript-autocomplete
Fix code-completion suggesting non-static members for custom classes
2023-02-06 23:02:12 +03:00
Yuri Sizov de4369ca4b
Merge pull request #72708 from KoBeWi/PackedMultilineStringArray
Fix @export_multiline for PackedStringArray
2023-02-06 23:01:16 +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
Rémi Verschelde eee343210d
Merge pull request #72330 from MinusKube/unreachable_code_bug
Fix unreachable code warning for elif block
2023-02-06 17:49:37 +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
Rémi Verschelde 8a37fad281
Merge pull request #72794 from vnen/gdscript-no-onready-without-node
GDScript: Don't allow @onready without inheriting Node
2023-02-06 15:41:02 +01:00
George Marques 3941af3d91
GDScript: Don't allow @onready without inheriting Node 2023-02-06 10:45:38 -03:00
Danil Alexeev 31749de128
GDScript: Better handling of `@rpc` annotation and autocompletion 2023-02-05 21:21:37 +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
kobewi 2b71ede967 Fix @export_multiline for PackedStringArray 2023-02-04 17:06:58 +01:00
Yuri Sizov 8753b07b05
Merge pull request #71860 from GeroVeni/master
Improve docs for rpc annotations
2023-02-04 18:43:15 +03:00
GeroVeni 54f2226ce5 Improve docs for rpc annotations 2023-02-04 13:28:41 +00:00
Pedro J. Estébanez 0bcc7bb5c7 Avoid losing references to objects in the native-scripting boundary 2023-02-03 17:48:41 +01:00
Rémi Verschelde 604493eb6e
Merge pull request #65910 from KoBeWi/gdsus
Cleanup function state connections when destroying instance
2023-02-03 16:13:06 +01:00
Rémi Verschelde a43ec333c4
Merge pull request #72398 from vnen/gdscript-setter-chain
GDScript: Improve usability of setter chains
2023-02-02 16:28:07 +01: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
Eric M 9b93bdb4e7 Fix crash in gdscript when autocompleting virtual function and signature does not match base. 2023-02-02 22:52:08 +10:00
Rémi Verschelde 824784f80b
Merge pull request #72557 from vonagam/fix-make-value-protection
GDScript: Fix getting reduced value of incomplete subscript for autocomplete
2023-02-02 09:49:37 +01:00
Danil Alexeev 4311836be2
GDScript: Fix crash in export group annotations 2023-02-02 08:37:39 +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 061b046401
Merge pull request #72499 from vonagam/fix-typed-array-disassembly
GDScript: Fix disassembly of typed array assignment and construction
2023-02-01 11:03:25 +01: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
Dmitrii Maganov 56aedb256e GDScript: Fix disassembly of typed array assignment and construction 2023-02-01 11:18:54 +02:00
Rémi Verschelde e101305950
Merge pull request #72487 from vnen/gdscript-warning-default-error
GDScript: Add warnings that are set to error by default
2023-02-01 08:23:42 +01:00
Rémi Verschelde 9aeda3b282
Merge pull request #72490 from resistor/disasm
Fix disassembly of OPCODE_CONSTRUCT_TYPED_ARRAY.
2023-02-01 08:02:04 +01:00
Rémi Verschelde ab2f8ab6ce
Merge pull request #72371 from dalexeev/remove-gds-str-duplicate
Remove `@GDScript.str` (duplicate of `@GlobalScope.str`)
2023-02-01 07:25:02 +01:00
Owen Anderson 835309c0a5 Fix disassembly of OPCODE_CONSTRUCT_TYPED_ARRAY.
Found while inspecting the bytecode for godot-benchmarks.
2023-01-31 21:52:51 -06: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
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
Rémi Verschelde dc7fb30485
Merge pull request #72400 from vnen/gdscript-match-release-consistency
GDScript: Fix match branches return check on release
2023-01-30 20:27:12 +01:00
George Marques 65407dd42d
GDScript: Fix match branches return check on release
The check for existence of `return` only existed on debug builds for
match branches. This could lead on an invalid error after exporting. Now
this is checked on relase too, so it works the same as the editor.
2023-01-30 15:18:36 -03:00
Dmitrii Maganov 011b3895db GDScript: Fix vararg method calls with exact arguments 2023-01-30 19:38:07 +02:00
Rémi Verschelde af57bdb193
Merge pull request #72305 from dalexeev/gfs-fix-export-enum
GDScript: Fix `@export_enum` works only with `int`
2023-01-30 14:47:12 +01:00