PLC-lang/rusty

Enhance missing argument validation

開放

#1,367 建立於 2024年11月22日

 (2 則留言) (0 個反應) (0 位負責人)Rust (71 個分叉)auto 404
enhancementgood first issuevalidation

倉庫指標

星標
 (351 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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 https://github.com/PLC-lang/rusty/issues/1364#issuecomment-2488507797

貢獻者指南