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

Explicitely disallow redefining module level fields #11232

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented May 18, 2023

Closes #10374

| statics, Some c ->
raise_typing_error_ext (make_error ~sub:[
make_error ~depth:1 (Custom "Previously defined here") c.cl_pos
] (Custom (Printf.sprintf "Cannot add module level fields for module %s" (s_type_path m.m_path))) loadp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrasing somehow suggests that this could be allowed for a different module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Module level fields are already defined for module %s" ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this makes me realize that we're not addressing the real problem here. This should be about adding module level fields to existing modules, whether or not they are already defined should not make a difference...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding module level fields to an existing module that does not have module level fields already works. It's only when it already has module level fields that we're having issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't sound right, I'll have to take a closer look at the original issue in that case...

Copy link
Contributor Author

@kLabz kLabz May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, repro from the issue is actually bad code since it's checking Context.getType with a module level field instead of a type, so always running defineModule.

It runs fine the first time because Test.hx has no module level fields, but obviously fails the next times because it is redefining the module level fields.

Edit: fixed link u_u

@Simn
Copy link
Member

Simn commented Feb 8, 2024

Do you know what the status here (and in #10374) is now?

@kLabz
Copy link
Contributor Author

kLabz commented Feb 8, 2024

As said on slack, we actually need to make it a bit more strict so this PR needs to be updated

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

Successfully merging this pull request may close these issues.

Context.defineModule on exists module with TDField not works
2 participants