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

Implement --noUnsafe compiler option #710

Merged
merged 5 commits into from
Jul 22, 2019
Merged

Implement --noUnsafe compiler option #710

merged 5 commits into from
Jul 22, 2019

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Jul 8, 2019

This is an initial implementation of the general idea of an "unsafe" compiler option as described in #709, but a bit simpler.

  • --noUnsafe
    Disallows the use of unsafe features in user code. Does not affect library files and external modules

This is fully backwards compatible in that the default is not changed, yet an embedder may now decide to disallow unsafe features in user code in order to protect from undefined behavior, like corruption of runtime structures by rogue stores and similar.

Instead of making stdlib files contagious as suggested in the original issue linked above, this PR refactors source kinds into

  • USER_ENTRY
    normal entry file where exports become module exports
  • USER
    normal file imported from user code
  • LIBRARY_ENTRY
    library entry file where exports become globals
  • LIBRARY
    normal library file

to keep all options open, e.g. if it ever becomes necessary to specify the file kind in asc. The runtime entry file is somewhat special in that it is both a library file and a user entry file (where exports become module exports), so it resorts to USER_ENTRY, since the RT entry doesn't use unsafe code anyway but just re-exports.

@dcodeIO
Copy link
Member Author

dcodeIO commented Jul 10, 2019

Should now handle most, if not all, of the possibilities where something unsafe is used and must be checked. If you notice something I've missed, please let me know :)

@dcodeIO
Copy link
Member Author

dcodeIO commented Jul 21, 2019

Last commit makes the implementation fully backwards compatible and much simpler, in that disallowing unsafe features is now opt-in. Updated the initial post accordingly. As such, I think we can just merge this without any further ado.

@dcodeIO dcodeIO changed the title Implement --unsafe compiler option Implement --noUnsafe compiler option Jul 21, 2019
@dcodeIO
Copy link
Member Author

dcodeIO commented Jul 22, 2019

Since no objections so far, and the new error handling being useful in an upcoming PR as it seems, I'm going to merge. Can still iterate upon the current state if there are additional requirements.

@dcodeIO dcodeIO merged commit fea328e into master Jul 22, 2019
@dcodeIO dcodeIO deleted the unsafe branch September 20, 2019 09:08
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.

1 participant