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

[minor] switch.ml: distinguish types for arguments, tests and actions #10516

Merged
merged 1 commit into from
Sep 20, 2021

Commits on Sep 20, 2021

  1. [minor] switch.ml: distinguish types for arguments, tests and actions

    Before this change, Switch will use 'make_if' either with tests
    explicitly constructed from the provided primitives, or with
    a matching scrutinee/argument directly to check that it is
    non-zero. (Arguments are expected to be implicitly coercible to
    booleans for the 'make_if' functions.)
    
    This assumption may not always hold, for example if we tried to define
    a switch construct on tagged integers in
    asmcomp/cmm_helpers.ml. (I have a followup commit doing just that.)
    The comparison primitives of Cmm return untagged booleans, the
    conditional test is untagged, but a tagged integer cannot be tested
    for non-zeroness by just using untagged 'if' directly.
    
    The present commit clarifies the matter by separating the type of
    actions, tests and arguments at the Switch level. It does not change
    behavior in any way, but it makes it much easier to follow these
    distinctions. (In particular, it the new typing discipline
    demonstrates that the dangerous use of 'make_if' only happens exactly
    once in the Switch functor.)
    gasche committed Sep 20, 2021
    Configuration menu
    Copy the full SHA
    46b5e1d View commit details
    Browse the repository at this point in the history