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

[Idea]: Make configuration tables read-only during runtime #1377

Open
vhyrro opened this issue Apr 4, 2024 · 1 comment
Open

[Idea]: Make configuration tables read-only during runtime #1377

vhyrro opened this issue Apr 4, 2024 · 1 comment
Labels
discussion Issue related to discussions, in preparation of a feature or bug fixes.

Comments

@vhyrro
Copy link
Member

vhyrro commented Apr 4, 2024

The documentation generator performs pretty heavy analysis of modules when generating its wiki. Because of this, it assumes that the public configuration has not been altered (the types of data have remained the same).

This contract can be freely broken by unsuspecting modules, leading the documentation generator to break in unpredictable ways. It may make sense to put a guard on the table after the user configuration has been applied to prevent data types from being altered.

This would involve wrapping the config.public table in a metatable which verifies that every write to __newindex preserves the type.

@vhyrro vhyrro added the discussion Issue related to discussions, in preparation of a feature or bug fixes. label Apr 4, 2024
@pysan3
Copy link
Contributor

pysan3 commented Apr 9, 2024

Just fyi I like how lua_ls overwrites shift left/right operator (>>, <<) to define and check config types.

https://github.com/LuaLS/lua-language-server/blob/master/script/config/template.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Issue related to discussions, in preparation of a feature or bug fixes.
Projects
None yet
Development

No branches or pull requests

2 participants