Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate init arg spec gives internal error #1542

Open
cgay opened this issue Nov 24, 2023 · 1 comment
Open

Duplicate init arg spec gives internal error #1542

cgay opened this issue Nov 24, 2023 · 1 comment
Labels
Compiler Warnings DRM DRM compliance issues

Comments

@cgay
Copy link
Member

cgay commented Nov 24, 2023

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 cgay added DRM DRM compliance issues Compiler Warnings labels Nov 24, 2023
@cgay
Copy link
Member Author

cgay commented Nov 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler Warnings DRM DRM compliance issues
Projects
None yet
Development

No branches or pull requests

1 participant