[m-rev.] for review: allow pragmas to accept pred() and func() wrappers around symname/arity

Peter Wang novalazy at gmail.com
Thu May 6 13:50:50 AEST 2021


On Wed, 05 May 2021 07:50:17 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> @@ -1151,25 +1166,40 @@ classify_plain_opt_items([Item | Items], !TypeDefns, !ForeignEnums,
>          ItemImplPragma = item_pragma_info(ImplPragma, Context, SeqNum),
>          (
>              (
> -                ImplPragma = impl_pragma_inline(SymNameArity),
> +                ImplPragma = impl_pragma_inline(SymNameArityMaybePF),
>                  Kind = pmpk_inline
>              ;
> -                ImplPragma = impl_pragma_no_inline(SymNameArity),
> +                ImplPragma = impl_pragma_no_inline(SymNameArityMaybePF),
>                  Kind = pmpk_noinline
>              ;
> -                ImplPragma = impl_pragma_promise_eqv_clauses(SymNameArity),
> +                ImplPragma =
> +                    impl_pragma_promise_eqv_clauses(SymNameArityMaybePF),
>                  Kind = pmpk_promise_eqv_clauses
>              ;
> -                ImplPragma = impl_pragma_promise_pure(SymNameArity),
> +                ImplPragma = impl_pragma_promise_pure(SymNameArityMaybePF),
>                  Kind = pmpk_promise_pure
>              ;
> -                ImplPragma = impl_pragma_promise_semipure(SymNameArity),
> +                ImplPragma = impl_pragma_promise_semipure(SymNameArityMaybePF),
>                  Kind = pmpk_promise_semipure
>              ;
> -                ImplPragma = impl_pragma_mode_check_clauses(SymNameArity),
> +                ImplPragma =
> +                    impl_pragma_mode_check_clauses(SymNameArityMaybePF),
>                  Kind = pmpk_mode_check_clauses
>              ),
> -            PredMarker = pragma_info_pred_marker(SymNameArity, Kind),
> +            SymNameArityMaybePF = pred_pfu_name_arity(PFU, SymName, Arity),
> +            (
> +                PFU = pfu_predicate,
> +                PredOrFunc = pf_predicate
> +            ;
> +                PFU = pfu_function,
> +                PredOrFunc = pf_function
> +            ;
> +                PFU = pfu_unknown,
> +                % When we create .opt files, we always specify PredOrFunc.
> +                unexpected($pred, "PFU = pfu_unknown")

The user may have .opt files created by previous versions of the
compiler around, so the chances of running into these mysterious
abort messages are quite high.

Peter


More information about the reviews mailing list