lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.5k stars 157 forks source link

ExternalSymbol: spec doesn't match actual #1507

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

The spec for ExternalSymbol in ASR.asdl states:

    | ExternalSymbol(symbol_table parent_symtab, identifier name,
        symbol external, identifier module_name, identifier* scope_names,
        identifier original_name, access access)

note particularly identifier* scope_names. This should be a vector of names, possibly empty, as in [lpython_builtin]. An example generated from tests/expr7.py does not match this spec:

 (ExternalSymbol
  2
  pow/__lpython_overloaded_0__pow
  6
  __lpython_overloaded_0__pow
  lpython_builtin  ;; <~~~~~~~ This element is not specified!
  []  ;; <~~~~~~~ This is probably the "scope_names"
  __lpython_overloaded_0__pow
  Public)

Looks like there is an extra element in ExternalSymbol that is not in the spec.

rebcabin commented 1 year ago

I now believe that the actual layout is

 (ExternalSymbol
  2  ;; symbol-table-id of parent symbol-table
  pow/__lpython_overloaded_0__pow  ;; name
  6  ;; symbol-table-ide of external symbol-table
  __lpython_overloaded_0__pow  ;; <~~~~~~~ This element is not specified!
  lpython_builtin  ;; module-name
  []  ;; <~~~~~~~ This is probably the "scope_names"
  __lpython_overloaded_0__pow  ;; original name
  Public  ;; access
)