Skip to content

Improve autocompletion and errors according to variable types - #9105

Open
D8H wants to merge 17 commits into
masterfrom
fix-bracket-error
Open

D8H wants to merge 17 commits into
masterfrom
fix-bracket-error

Conversation

@D8H

@D8H D8H commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator
  • Add autocompletion with brackets access for structures and arrays.
  • Improve error messages when brackets are empty.
  • Fix autocompletion of variable parameters in function calls wrongly suggesting objects and functions.
  • Only display relevant variables in autocompletion according to their type.
  • Display an error when string, number or boolean variable is used and a structure or an array is expected and the other way around.

@D8H
D8H requested a review from 4ian as a code owner September 15, 2026 12:38
@D8H D8H changed the title Improve autocompletion and errors according to varia Improve autocompletion and errors according to variable types Sep 15, 2026
@D8H
D8H marked this pull request as draft September 15, 2026 12:39
@D8H
D8H force-pushed the fix-bracket-error branch from 6385d2c to 87df623 Compare September 19, 2026 15:30
@D8H
D8H marked this pull request as ready for review September 19, 2026 15:34
4ian pushed a commit that referenced this pull request Sep 21, 2026
These tests reproduce 2 issues found while reviewing #9105. They are
expected to fail until the corresponding code is fixed.

- "primitive" is ignored for "variableOrProperty" and
  "variableOrPropertyOrParameter" parameters. ExpressionValidator only
  checks Type::Variable, Type::ObjectVariable and Type::LegacyVariable,
  so the 6 built-in variable conditions and actions declaring
  "primitive" never raise an error on a structure or an array.

- isIntoBrackets is reset to false instead of being restored in
  OnVisitVariableBracketAccessorNode, so a nested bracket accessor makes
  the following empty node fall back to the generic message instead of
  the bracket specific one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U3gfFre6be5CeT4rhTCeST

namespace gd {

struct TypeAndExtraInfo {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra double space

auto parentParameterExtraInfo = currentParameterExtraInfo;
currentParameterExtraInfo = nullptr;
currentParameterExtraInfo = "";
isIntoBrackets = true;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need a "stack" of this for nested bracket. Check this test: de4e2f8#diff-2e73971cd51c6b4bd23506151af0c5b315d285a8e5d1ce72990fa70b2421a9e2R4695

(in practice, this is only I think to make sure the error messages are as precise as possible)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make it isDirectParentBracketAccessor and put it back to false as soon as we enter another node.

"to access. For example: `MyVariable[0]`."),
childNameLocation);
}
} else if ((parentType == Type::Variable ||

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also handle Type::VariableOrProperty and Type::VariableOrPropertyOrParameter?

See new test: de4e2f8#diff-2e73971cd51c6b4bd23506151af0c5b315d285a8e5d1ce72990fa70b2421a9e2R2480

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are already existing errors:

  • "Properties can't have children"
  • "Accessing a child variable of a property is not possible"

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants