alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

Prefer membership test to increase readability #1240

Open pjljvandelaar opened 1 year ago

pjljvandelaar commented 1 year ago

Dear Alire developers,

Alire doesn't always use the membership test where possible. I hope you agree with me that the coming pull request is an improvement.

Greetings, Pierre

Problem detected and solved by Rejuvenation-Ada crate vote for Rejuvenation-Ada as The 2022 Ada Crate Of The Year

pjljvandelaar commented 1 year ago

Compiler had problems with different types in variable and values. Despite http://www.ada-auth.org/standards/22aarm/html/aa-4-5-2.html

3.a/2
Reason: {[AI95-00230-01](http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00230.TXT)} The part of the rule for untagged types is stated in a way that ensures that operands like a string literal are still legal as operands of a membership test.
3.c/3
{[AI05-0158-1](http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AI05s/AI05-0158-1.TXT)} The special rule for determining the tested type for elementary types is to allow numeric literals in [membership_choice_list](http://www.ada-auth.org/standards/22aarm/html/AA-4-4.html#S0136)s. Without the rule, A in B | 1 would be illegal as B and 1 would have different types (the literal having type universal integer).

Now added check to ensure same type.