Skip to content

Verify parameter count for operators #143

@kindlich

Description

@kindlich

Currently, it is possible to define an operator with any number of arguments.
However, we only support the operators:

  • Unary operators (whose header does not accept any parameter) public !(): Money
    • NEG, INVERT, NOT
  • binary operators (whose header accepts a single parameter) public +(other: Money): Money
    • ADD, SUB, MUL, DIV, MOD, CAT, OR, AND, XOR, INDEXGET, CONTAINS, COMPARE, EQUALS, NOTEQUALS, SHL, SHR, (MEMBERGETTER)
    • Their xxxAssign variants (ADD_ASSIGN, ...)
  • The MEMBERSETTER ternary operator (whose header accepts 2 parameters) public .=(name: string, amount: Money): void
  • Special Case: The indexSet operator can be registered to accept 2 or more parameters, with the last one being the value being set and all before the (multi-dim) indices
    • public []=(index: usize, value: bool): void
      is called using flags[10] = true;
    • public []=(x: usize, y: usize: value: bool): void
      is called using quadrantChecked[1, 3] = true
    • ...

If a user writes a script where they attempt to create an operator with an invalid parameter count, then the validator should log an error and no scripts should be executed.

CompileExceptionCode: INVALID_PARAMETER_COUNT
Message: "operator parameter count mismatched, X operator only supports Y paremters"

public +(other as int, other_other as int) {

}

Acceptance criteria:

  • For each below, write two tests, one that creates the operator with the proper parameters and has the script executed, and one that uses an invalid number of parameters and therefore fails
    • ADD
    • SUB
    • MUL
    • DIV
    • MOD
    • CAT
    • OR
    • AND
    • XOR
    • NEG
    • INVERT
    • NOT
    • INDEXSET (with 1 index variable, 2 index variables and check if overload of is possible)
    • INDEXGET
    • CONTAINS
    • COMPARE
    • EQUALS
    • NOTEQUALS
    • SHL
    • SHR
    • MEMBERGETTER Operator not yet implemted, this is outside the scope of this task
    • MEMBERSETTER Operator not yet implemted, this is outside the scope of this task

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions