opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

No error when wrong keyword arg passed to bare method

Open cgay opened this issue 5 years ago • 2 comments

This assertion in dylan-test-suite fails:

  check-condition("one key call wrong supplied", <error>,
                  begin
                    local method m (#key x) x end;
                    // Stifle compiler warning we get if called directly.
                    let methods = list(m);
                    methods[0](y: 1);
                  end);

From https://opendylan.org/books/drm/Parameter_Lists, "If a function that accepts keyword arguments is called, it will signal an error if called with a keyword argument that it does not permit...." A bare method like this without #all-keys or #rest doesn't permit y:.

cgay avatar Dec 29 '19 22:12 cgay

This looks like the same issue to me, but with #rest:

  check-condition("rest one key call one arg", <error>,
                  begin
                    local method m (#rest k, #key) k end;
                    // Stifle compiler warning we get if called directly.
                    let methods = list(m);
                    methods[0](y: 1)
                  end);

cgay avatar Dec 29 '19 22:12 cgay

Yes, I made note of this in the dylan-lang/general chat on 2019-11-01. Some, but not all, of the entry point code (in both C and LLVM back-ends) check for invalid keywords.

housel avatar Dec 30 '19 01:12 housel