Ampersand icon indicating copy to clipboard operation
Ampersand copied to clipboard

PrototypeContext.adl does not compile

Open stefjoosten opened this issue 1 year ago • 1 comments

What happened

I tried to compile the AmpersandData/PrototypeContext/PrototypeContext.adl` code with the Ampersand-v5.0.0 compiler, expecting it to compile stand-alone. This code is used to generate prototypes, so I know apriori that it is correct. However, I got compiler errors:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:44:82 error:
  A relation is used that is not defined: pf_ifcRoles ==============================
/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:44:97 error:
  A relation is used that is not defined: pf_navItemRoles ==============================

Surprisingly, I could not find declarations of the missing relations anywhere in the entire Ampersand repo. So, I speculated that maybe these are "magical declarations" and decided to add these declaratioins in PrototypeContext.adl. An unlikely speculation, but then, a second declaration of the same thing doesn't hurt in Ampersand.

  RELATION pf_ifcRoles[Interface*Role] 
  RELATION pf_navItemRoles[NavMenuItem*Role]

Now I got type conflicts:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:77:132 error:
  Type error, cannot match:
    the concept PF_NavMenuItem (Src of I[PF_NavMenuItem ])
    and concept NavMenuItem (Src of isSubItemOf [NavMenuItem *NavMenuItem ];isSubItemOf [NavMenuItem *NavMenuItem ]~)==============================
/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Interfaces.adl:24:82 error:
  Type error, cannot match:
    the concept Interface (Tgt of isPublic [Interface *Interface ])
    and concept PF_Interface (Src of V [PF_Interface *Role ])==============================

I figured that maybe there is more magic in this thing. So, I added

  CLASSIFY Interface IS PF_Interface
  CLASSIFY NavMenuItem IS PF_NavMenuItem

But the search wasn't over. I now got stuck with four compiler errors, the first of which reads:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:77:111 error:
  Type error, cannot match:
    the concept NavMenuItem (Src of I[PF_NavMenuItem ]-isSubItemOf [NavMenuItem *NavMenuItem ];isSubItemOf [NavMenuItem *NavMenuItem ]~)
    and concept PF_NavMenu (Src of I[PF_NavMenu ])==============================

Now I'm really puzzled because this is code that runs correctly when I use it to generate prototypes. I inspected the code of the prototype framework to see which part of the metamodel it uses. This appears to be

    const
        REL_IFC_ROLES               = 'pf_ifcRoles[PF_Interface*Role]',
        REL_IFC_IS_PUBLIC           = 'isPublic[PF_Interface*PF_Interface]',
        REL_IFC_IS_API              = 'isAPI[PF_Interface*PF_Interface]',
        REL_IFC_LABEL               = 'label[PF_Interface*PF_Label]',
        REL_ROLE_LABEL              = 'label[Role*PF_Label]',
        REL_SESSION_ALLOWED_ROLES   = 'sessionAllowedRoles[SESSION*Role]',
        REL_SESSION_ACTIVE_ROLES    = 'sessionActiveRoles[SESSION*Role]',
        REL_NAV_LABEL               = 'label[PF_NavMenuItem*PF_Label]',
        REL_NAV_IS_VISIBLE          = 'isVisible[PF_NavMenuItem*PF_NavMenuItem]',
        REL_NAV_IS_PART_OF          = 'isPartOf[PF_NavMenuItem*PF_NavMenu]',
        REL_NAV_IFC                 = 'ifc[PF_NavMenuItem*PF_Interface]',
        REL_NAV_SEQ_NR              = 'seqNr[PF_NavMenuItem*PF_SeqNr]',
        REL_NAV_SUB_OF              = 'isSubItemOf[PF_NavMenuItem*PF_NavMenuItem]';

@Michiel-s, can you explain to me what I cannot explain?

What I expected

Version of ampersand that was used

Steps to reproduce

Screenshot / Video

Context / Source of ampersand script

stefjoosten avatar Jan 20 '24 07:01 stefjoosten