Thread overview
[Issue 21992] importC: Error: variable is used as a type
Jun 04, 2021
Iain Buclaw
Jun 27, 2021
Walter Bright
Jun 27, 2021
Walter Bright
Jun 28, 2021
Iain Buclaw
Jun 28, 2021
Iain Buclaw
Jul 04, 2021
Dlang Bot
Jul 04, 2021
Dlang Bot
June 04, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ImportC, rejects-valid
                 CC|                            |ibuclaw@gdcproject.org

--
June 27, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
Unfortunately, the (i)*2 can be parsed as either a multiply of i*2 or a cast of
*2 to type i.

This can only be distinguished in the semantic phase when what i is is known.

--
June 27, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Because ( ) are not seen by the semantic code, the best solution is for the parser to turn (i)*2 into a cast expression. Then, if the semantic pass determines that i is a variable, rewrite the cast expression into a multiply.

Do the analogous thing for -, +, and & operators.

--
June 28, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Walter Bright from comment #2)
> Because ( ) are not seen by the semantic code, the best solution is for the parser to turn (i)*2 into a cast expression. Then, if the semantic pass determines that i is a variable, rewrite the cast expression into a multiply.
> 
> Do the analogous thing for -, +, and & operators.
Yes, this is what I have in the pipeline already.

--
June 28, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

--- Comment #4 from Iain Buclaw <ibuclaw@gdcproject.org> ---
At the moment I do have some lvalue checking in the parser, this'll have to be moved to semantic as well.  But there are some hurdles to overcome - mostly from the semantic lowering rvalues into lvalues.

For example, this nudges support in the right direction: https://github.com/dlang/dmd/pull/12752

--
July 04, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ibuclaw created dlang/dmd pull request #12808 "fix Issue 21992 - importC: Error: variable is used as a type" fixing this issue:

- fix Issue 21992 - importC: Error: variable is used as a type

https://github.com/dlang/dmd/pull/12808

--
July 04, 2021
https://issues.dlang.org/show_bug.cgi?id=21992

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12808 "fix Issue 21992 - importC: Error: variable is used as a type" was merged into master:

- fb4583eb93aba712bcbcda5d7bdf6303d6c1416e by Iain Buclaw:
  fix Issue 21992 - importC: Error: variable is used as a type

https://github.com/dlang/dmd/pull/12808

--