Skip to content

(all) #43 Implement support for optional typing

Per Lundberg requested to merge feature/support-optional-typing into master

This took a while 😉 but I'm quite happy about the overall result. Will wait a day or two before merging this, but all unit tests are now passing at least, and most WIP code should be cleaned up.

Supported functionality as of this MR

  • Types can be specified for local variables. They can also be inferred from their usage.

    var a: int = 32;
    var a = 42; // inferred to int
  • Variable types can also be inferred from e.g. calling functions, the result of binary operators etc:

    fun f(): int {
      return 42;
    }
    
    var a = f();          // inferred to int
    var b = 32 * 42 * 52; // likewise

Limitations

  • Function parameters and return types are currently mandatory; they cannot be inferred from their usage (as in TypeScript). This is something we aim to fix within the scope of #43 in the longer run.

    // The type specifiers below are currently mandatory
    fun f(s: string): int {
    }

Merge request reports

Loading