Closed stdc105 closed 1 year ago
Whoops, apparently we don't use DsGrids in any of our projects!
The accessor fix will be in the next version (after 1.3.2) by end of day Central Time.
I'm not sure why the global is ending up with an Any
type, though using global.X
is challenging for the parser since it's not possible to determine which global.X =
assignment is the initial declaration (Stitch uses the declaration, or the first discovered assignment to determine the type).
If you use globalvar
to declare them that might resolve it, since that unambiguously indicates where the declaration of that variable is.
This is great! Unfortunately we're using global.STUFF
to define all of our global variables and we may not be able to change them right now, but that's okay, "Find References" works on global and in most cases I know the types already. Thank you for all the help and fixes!
Yeah the global thing is just sorta incompatible with static analysis, unfortunately.
Since Stitch only assigns types when things are assigned, you should be able to ensure that a type is correct for a given global.X
if you:
global.X = ...
/// @type {TheType}
JSDoc above it (this is a Stitch extension to Feather's JSDocs)Stitch gives the /// @type {TheType}
directive precedence over inferred types, so as long as you can ensure that the first assignment Stitch sees is explicitly typed like that (by explicitly typing all assignments) you should end up with what you want.
Note that Stitch works from top to bottom on files, so you would only need to explicitly type a global's first assignment in a given file.
The latest version (1.4.0) was just published a moment ago and includes the DsGrid accessor fix, among a bunch of other fixes.
Sample offender code:
Script::data_load.gml
Expected: Stitch doesn't show error on comment 1 Actual: Stitch is reporting 2 errors on comment 1:
Expecting token of type --> EndBracket <-- but found --> ',' <--
on comma, andRedundant input, expecting EOF but found: ]
on closing square bracket.In addition, if
_grid
is a local variable (defined byvar
) or an object field (defined without prefix), it shows the correct type ofId.DsGrid
; but if it's a global variable underglobal.SOMETHING = ds_grid_create(5, 5)
, it will show typeANY
.Bug report environment: Windows 11 Pro 22H2 (22621.1928) GameMaker BETA IDE v2023.400.0.324 Runtime v2023.400.0.342 VSCode 1.80.0 (user setup) Stitch VSCode 1.3.0