Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance missing argument validation #1367

Open
volsa opened this issue Nov 22, 2024 · 0 comments
Open

Enhance missing argument validation #1367

volsa opened this issue Nov 22, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers validation candidate for syntactic or semantic validation

Comments

@volsa
Copy link
Member

volsa commented Nov 22, 2024

Currently we have two different error messages for missing arguments, either a

  • "Argument <name> is missing" or a
  • "this POU takes 1 argument but 0 arguments were supplied"

A better approach would be to merge both these validations into one, displaying something along Argument(s) <list of names separated by a comma> are missing


FUNCTION_BLOCK foo
VAR_INPUT 
   x : DINT := 34;
END_VAR
METHOD bar 
VAR_INPUT 
   x : DINT := 34;
END_VAR
END_METHOD
END_FUNCTION_BLOCK 

FUNCTION baz
VAR_INPUT 
   x : DINT := 34;
END_VAR
END_FUNCTION

FUNCTION main : DINT 
VAR 
   fb: foo;
END_VAR
   fb.bar();
   baz();
END_FUNCTION

Both the calls to fb.bar and baz have the same error, yet yield different diagnostics:

error[E030]: Argument `x` is missing
   ┌─ target/demo.st:22:5
   │
22 │     fb.bar();
   │     ^^^^^^ Argument `x` is missing

error[E032]: this POU takes 1 argument but 0 arguments were supplied
   ┌─ target/demo.st:23:5
   │
23 │     baz();
   │     ^^^ this POU takes 1 argument but 0 arguments were supplied

Compilation aborted due to critical errors.

Originally posted by @mhasel in #1364 (comment)

@volsa volsa added enhancement New feature or request good first issue Good for newcomers validation candidate for syntactic or semantic validation labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers validation candidate for syntactic or semantic validation
Projects
None yet
Development

No branches or pull requests

1 participant