lock3 / cppx

Extensions to Clang for Compiling the Blue & Gold Languages
29 stars 4 forks source link

Issue causing dependent type names inside of a member access expression to crash #83

Closed bbartman closed 3 years ago

bbartman commented 3 years ago

Offending code:

new_allocator[T:type] : type = class{
  rebind[T1:type] : type = class { other : type = new_allocator[T1]; }

  init()<noexcept>:void !{ }
}

_Vector_Base[T:type, Alloc:type] : type = class:
  T_alloc_type : type = Alloc.rebind[T].other
  _Vector_Impl : type = class(T_alloc_type) {
    constructor()! {
      this.(T_alloc_type)init();
    }
  }

After some investigation I discovered that the expression this.(T_alloc_type)init(); is being parsed incorrectly

It's being parsed as

Call 0x11d73190
|-Atom 0x11d73060 operator'.'
`-List 0x11d73148
  |-Atom 0x11d72bd0 this
  `-Call 0x11d73018
    |-Atom 0x11d72ee8 operator'()'
    `-List 0x11d72fd0
      |-Atom 0x11d72ca8 T_alloc_type
      `-Call 0x11d72ea0
        |-Atom 0x11d72d80 init
        `-List 0x11d72e58

when it should be

Call // Function Call 
| Call 0x11d4fa90
|  |-Atom 0x11d4f960 operator'.'
| `-List 0x11d4fa48
|   |-Atom 0x11d4f560 this
|   `-Call 0x11d4f918
|     |-Atom 0x11d4f7e8 operator'()'
|     `-List 0x11d4f8d0
|       |-Atom 0x11d4f638 T_alloc_type
|       `-Atom 0x11d4f710 init
`List // The actual function call arguments
bbartman commented 3 years ago

This currently works as (this.(T_alloc_type)init)(). It parses like this but elaboration fails.

bbartman commented 3 years ago

Elaboration has been fixed but parsing has not been addressed yet.

sdgoodrick commented 3 years ago

we discussed before changing the grammar like so:

postfix:
  // ...
  primary . id-expression
  primary . ( id-expression ) id-expression

meaning this disambiguator thing can only come after this., which makes enough sense to me

sdgoodrick commented 3 years ago

fixed but leaving the issue open because i'm not sure i want to commit to only having these be postfix yet