opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

Duplicate init arg spec gives internal error

Open cgay opened this issue 2 years ago • 1 comments

define class <c> (<object>)
  keyword aaa:;
  keyword aaa:;
end;
format-out("%s\n", make(<c>, aaa: 1));

(Available here: https://play.opendylan.org/shared/93b97d88a4b522b9)

Results in this output:

Open Dylan 2023.1
Internal error: value @KaaaHLcGVplay_bba5f31d926f is multiply defined
Exiting with return code 9

From https://opendylan.org/books/drm/Instance_Creation_and_Initialization, the last paragraph in the section "Initialization Argument Specifications" (emphasis mine):

""" More than one keyword initializable slot may be initialized from the same initialization argument (that is, more than one keyword initializable slot may specify the same init-keyword). However, an error is signaled if a single define-class form has more than one initialization argument specification for the same keyword. An error will also be signaled if a single define-class form has a keyword initializable slot that includes an init specification and also includes an initialization argument specification for the same keyword that is either required or provides a default value. These error situations are all indications of code that can never be reached. """

cgay avatar Nov 24 '23 17:11 cgay

Adding this to the same bug on the theory that the problems are in the same code...

No error is signaled for this example:

define class <c> (<object>)
  slot one, init-keyword: aaa:, init-value: "one";
  required keyword aaa: = "two";
end;
ignore(one, one-setter);
format-out("%s\n", one(make(<c>, aaa: 1)));

(Available here: https://play.opendylan.org/shared/48cfddccfa9aa2ff)

From the same paragraph quoted in the initial bug description:

An error will also be signaled if a single define-class form has a keyword initializable slot that includes an init specification and also includes an initialization argument specification for the same keyword that is either required or provides a default value.

cgay avatar Nov 24 '23 18:11 cgay