Commit graph

79 commits

Author SHA1 Message Date
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
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
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
George Marques fd643c903d
GDScript: Add annotation to ignore warnings 2022-01-04 09:32:43 -03: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
Pawel Lampe 1a15a3adf6 Fix GDScript parser crash on 'dollar mixed with assignment' expression
fixes #53696
2021-11-21 21:18:46 +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 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
Brian Semrau 0ff0f64cd4 GDScript: Access outer scope classes 2021-10-13 22:39:12 -04:00
Rémi Verschelde e4288bf728
Merge pull request #53720 from vnen/gdscript-typed-array-custom-class 2021-10-12 16:51:50 +02:00
George Marques 34288b24a6
GDScript: Fix typed array with custom classes 2021-10-12 10:41:04 -03:00
George Marques 45f546c1d8
GDScript: Make setter parameter type same as variable type 2021-10-12 09:39:23 -03:00
George Marques f930d54140
Merge pull request #53103 from ZuBsPaCe/gdscript-analyze-properties-fix
GDScript: Report property type errors
2021-10-11 11:01:39 -03:00
mashumafi 575d4e00b6 Enhance and cleanup stringify for Vector 2021-10-09 06:19:25 +00:00
ZuBsPaCe 551ceb590b GDScript: Report property type errors
Inline getters & setters are now FunctionNodes.
Their names are set in the parser, not in the compiler.
GDScript-Analyzer will now run through getter and setter.
Also report wrong type or signature errors regarding getset properties.
Added GDScript tests for getters and setters.
#53102
2021-10-08 22:06:15 +02:00
Rémi Verschelde 49e7e049ab
Merge pull request #53422 from KoBeWi/add_LUA_to_Godot 2021-10-07 23:37:37 +02:00
Rémi Verschelde 98b81ad35c
Merge pull request #53479 from vnen/gdscript-subscript-object-self 2021-10-06 19:48:23 +02:00
George Marques 1f55bd190c
GDScript: Allow subscript on self and object types 2021-10-06 12:01:34 -03:00
George Marques 6bdb28f5e4
GDScript: Avoid hard errors on inferred types
Since inference isn't always correct, they are now treated as unsafe
instead of errors.

This also removes inferred type when a variable is reassigned. Since
it's not aware of branching, the types might become invalid in a later
context.
2021-10-06 11:42:19 -03:00
George Marques d6c799006a
GDScript: Make all warnings enabled in test generation
The test generation doesn't initialize the language (since it's already
initialized in main), but it still needs the warning enabled so it
matches the actual tests.
2021-10-06 11:39:00 -03:00
kobewi 9e5fdbc79d Fix LUA-style assignment in Dictionary 2021-10-05 12:17:13 +02:00
George Marques 84956fee4b
GDScript: Fix member assignment with operation
It was wrongly updating the assigned value with the result of the
operation.
2021-10-04 14:09:54 -03:00
Rémi Verschelde 27d4e2f09f
Merge pull request #53216 from vnen/gdscript-builtin-type-not-id 2021-09-29 17:04:24 +02:00
George Marques 72c07708e8
GDScript: Don't allow builtin type names as identifiers 2021-09-29 11:23:16 -03:00
George Marques 991f4d8527
GDScript: Fix assignment with operation for properties 2021-09-29 10:54:16 -03:00
Rémi Verschelde 679f70c1e1
Merge pull request #52906 from vnen/gdscript-show-error-on-yield 2021-09-21 20:36:39 +02:00
Rémi Verschelde b3b4860d2e
Merge pull request #52905 from vnen/gdscript-single-line-declaration 2021-09-21 20:35:36 +02:00
George Marques 262d6c6bef
GDScript: Show specific error when "yield" is used
To help people porting code, it gives a hint to use "await" instead of a
generic error.
2021-09-21 14:38:14 -03:00
George Marques e5ebc9710d
GDScript: Allow classes declaration to be done in single line
Incidentally, allow multiple statements in single line functions when
using semicolon as a terminator.
2021-09-21 14:14:46 -03:00
George Marques bab0afc821
GDScript: Allow multiple lines in signal parameters declaration 2021-09-21 13:40:39 -03:00
Rémi Verschelde 82c12060b2
Merge pull request #52718 from Calinou/gdscript-add-integration-tests-2 2021-09-21 14:13:24 +02:00
Rémi Verschelde 424ddcba37
Merge pull request #52792 from vnen/gdscript-subscript-missing-index 2021-09-17 20:16:29 +02:00