AdaCore/langkit

Calling AST node "Length" breaks compilation

senier opened this issue · 1 comments

How to reproduce

Create an example project:

create-project.py repro

Change ExampleNode to Length:

$ sed -ie 's/ExampleNode/Length/' repro/language/parser.py
$ cd repro && python3 ./manage.py make
[...]
Compile
   [Ada]          parse.adb
parse.adb:137:44: "Length" is not visible
parse.adb:137:44: multiple use clauses cause hiding
parse.adb:137:44: hidden declaration at libreprolang-analysis.ads:88
parse.adb:137:44: hidden declaration at a-strunb.ads:92

   compilation of parse.adb failed

gprbuild: *** compilation phase failed
Build failed: error while running gprbuild -p -j8 -P/home/senier/tmp/langkit/length_issue/repro/build/src/mains.gpr -XBUILD_MODE=dev -XLIBRARY_TYPE=relocatable -XGPR_BUILD=relocatable -XXMLADA_BUILD=relocatable parse.adb:
    Command '['gprbuild', '-p', '-j8', '-P/home/senier/tmp/langkit/length_issue/repro/build/src/mains.gpr', '-XBUILD_MODE=dev', '-XLIBRARY_TYPE=relocatable', '-XGPR_BUILD=relocatable', '-XXMLADA_BUILD=relocatable', 'parse.adb']' returned non-zero exit status 4.

Expected behavior

Either reject Length as AST node name or (preferably) allow it's use in the parser by fully qualifying Ada.Strings.Unbounded.Length (maybe use clauses should be avoided in generated code alltogether).

Versions used

GNAT: Community 2020
Langkit: master (45df941)

Hello @senier!

We are aware of this class of issue (name conflicts in the generated code from otherwise correct language spec). It’s very delicate: unfortunately, avoiding use clauses will both increase the complexity of the code generator and not fix the issue once and for all. We’ll keep this issue open, as we want to get this fixed eventually, but it’s not clear how and when at this stage.