Commit Graph

502 Commits

Author SHA1 Message Date
a7029e4c8a Merge pull request #91364 from vnen/gdscript-implicit-ready-base-first
GDScript: Call implicit ready on base script first
2024-05-02 17:31:32 +02:00
99b702ea3d GDScript: Call implicit ready on base script first
It is generally expected that the base class is called before the
inherited clas. This commit implements this behavior for the implicit
ready function (`@onready` annotation) to make it consistent with the
expectations.
2024-05-02 11:25:52 -03:00
c4e24d2b3b [GDScript] Correctly report invalid read-only access 2024-05-01 12:28:47 +02:00
731ea17dd4 Merge pull request #91192 from vnen/gdscript-validated-native-static-calls
GDScript: Perform validated calls with static methods
2024-05-01 09:55:04 +02:00
273a643145 Merge pull request #89647 from AThousandShips/read_only_dict
[Core] Fix property access on read-only `Dictionary`
2024-05-01 09:54:48 +02:00
2778069025 GDScript: Fix object iterator opcodes 2024-04-26 09:21:55 +03:00
7ca038effa GDScript: Perform validated calls with static methods
When the types are validated at compile time, this type of call runs
faster. It is already used for instance methods, this adds this
optimization to native static methods as well.
2024-04-25 21:19:40 -03:00
4136ed7fc8 GDScript: Fix test reset_uninit_local_vars.gd failure 2024-04-24 20:49:52 +03:00
69a23e64e4 Merge pull request #89990 from dalexeev/gds-reset-uninit-local-vars
GDScript: Fix uninitialized local variables not being reset
2024-04-24 18:54:56 +02:00
6b28cb6721 Merge pull request #89884 from HolonProduction/tests-batch-2
Completion Tests: Add script to owner
2024-04-23 19:10:57 +02:00
ec29c3e784 [Core] Fix property access on read-only Dictionary 2024-04-22 13:57:34 +02:00
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
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
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
684e7aa37a Merge pull request #89472 from dalexeev/gds-fix-bin-tokenizer-continuation-lines
GDScript: Fix continuation lines in `GDScriptTokenizerBuffer`
2024-04-15 18:14:38 +02:00
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
74177d79c9 Fix multiline array/dictionary match statements
Currently array and dictionary expressions cannot be spread over
multiple lines in match statements.

Adding mutliline push/pop while parsing the pattern for bracket and
brace enables the ability for these to be multiline. This enables more
complex patterns to be matched without exceeding line limits.

Fixes #90372
2024-04-12 10:59:28 +02:00
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
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
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
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
02253b6b91 GDScript: Fix continuation lines in GDScriptTokenizerBuffer 2024-04-10 08:51:02 +03:00
9a9045cf7a Merge pull request #89382 from dcaoc03/master
Fix enum autocompletion for core classes
2024-04-09 22:25:13 +02:00
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
809c6817be Add tests for signal await with parameters 2024-04-08 19:12:01 +02:00
27d7760f41 GDScript: Fix uninitialized local variables not being reset 2024-03-30 23:25:30 +03:00
d2c2194937 Completion Tests: Add script to owner 2024-03-25 16:17:44 +01:00
db455e5bee [Core] Disconnect one-shot signals before calling callbacks
This prevents infinite recursion with one-shot connections emitting
themselves
2024-03-20 20:24:44 +01:00
935ea10f3a Fixed enum autocompletion for core classes (Issue #88858)
Minor fix consisted in the use of [[fallthrough]] macro
2024-03-15 20:20:36 +00:00
a1c476f9d7 Merge pull request #87680 from AThousandShips/the_angry_count
Add methods to get argument count of methods
2024-03-13 22:16:43 +01:00
ef1909fca3 GDScript: Fix @warning_ignore annotation issues 2024-03-12 19:00:06 +03:00
59bcc2888c Add methods to get argument count of methods
Added to:
* `Callable`s
* `Object`s
* `ClassDB`
* `Script(Instance)`s
2024-03-10 11:02:43 +01:00
0acc4276b6 Merge pull request #82952 from AbelToy/gds-export-array
Allow `@export`ed Arrays to set property hints for their elements
2024-03-06 09:49:53 +01:00
882441a0ad Support Array and PackedArray in @export_* 2024-03-06 16:17:54 +09:00
1e61e42250 [GDScript] Fix some test file paths 2024-03-04 19:11:28 +01:00
7be96a55c4 Merge pull request #86973 from HolonProduction/tests-batch-1
Add tests for `get_node` autocompletion
2024-03-04 13:32:55 +01:00
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
a2e7c64dc4 Cleanup 2024-03-01 13:06:37 +01:00
1f42455e0a Debugging additions 2024-03-01 11:38:49 +01:00
fc7d7d3dae Add test for get_node autocompletion 2024-03-01 11:24:06 +01:00
d90c9db27f Core: Add Callable.create static method for Variant callables 2024-02-29 10:45:00 +03:00
21ee3716c2 Merge pull request #82122 from dalexeev/gds-add-export-hidden-annotation
GDScript: Add `@export_storage` annotation
2024-02-27 21:22:49 +01:00
77666286b7 Merge pull request #88020 from emre0altan/match-null-crashes-GDScript-compiler
GDScript: Set `has_type` false if it is `BUILTIN` but `Variant::NIL`
2024-02-23 22:18:55 +01:00
d7a72d72e6 Fix running tests in template builds 2024-02-22 18:05:42 +01:00
081fa324fd set has_type false if it is BUILTIN but Variant::NIL 2024-02-11 13:47:12 +00:00
72e5f8c31e GDScript: Enable compression on export
Besides the regular option to export GDScript as binary tokens, this
also includes a compression option on top of it. The binary format
needs to encode some information which generally makes it bigger than
the source text. This option reduces that difference by using Zstandard
compression on the buffer.
2024-02-08 11:20:07 -03:00
b4d0a09f15 GDScript: Reintroduce binary tokenization on export
This adds back a function available in 3.x: exporting the GDScript
files in a binary form by converting the tokens recognized by the
tokenizer into a data format.

It is enabled by default on export but can be manually disabled. The
format helps with loading times since, the tokens are easily
reconstructed, and with hiding the source code, since recovering it
would require a specialized tool. Code comments are not stored in this
format.

The `--test` command can also include a `--use-binary-tokens` flag
which will run the GDScript tests with the binary format instead of the
regular source code by converting them in-memory before the test runs.
2024-02-08 11:20:05 -03:00
7223c5b54a Fix various typos with codespell
Using 2.2.7.dev115+g0eb441d6.

Had to add `cancelled` to the ignore list, as it's a Wayland signal which
we're handling in our code, so we don't want codespell to fix that "typo".

Also includes the typo fix from #87927.

Co-authored-by: Divyanshu Shekhar <61140213+divshekhar@users.noreply.github.com>
2024-02-07 11:09:34 +01:00
2bf25954b4 GDScript: Add is not operator 2024-02-04 17:36:53 +03:00
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