OpenZeppelin / solidity-docgen

Documentation generator for Solidity projects
MIT License
450 stars 118 forks source link

TypeError: importedScope[a.foreign.name] is not a function - probably due to `import "" as X;` syntax #426

Closed lnist closed 1 year ago

lnist commented 1 year ago

As mentioned in #415 we see another instance of this error (on 0.6.0-beta-31):

TypeError: importedScope[a.foreign.name] is not a function
    at scope.<computed> (/home/my/src/node_modules/solidity-docgen/src/utils/scope.ts:39:116)
    at /home/my/src/node_modules/solidity-docgen/src/utils/scope.ts:10:56
    at mapValues (/home/my/src/node_modules/solidity-docgen/src/utils/map-values.ts:4:14)
    at getContractsInScope (/home/my/src/node_modules/solidity-docgen/src/utils/scope.ts:10:14)
    at parseNatspec (/home/my/src/node_modules/solidity-docgen/src/utils/natspec.ts:104:49)
    at natspec (/home/my/src/node_modules/solidity-docgen/src/common/properties.ts:18:22)
    at /home/my/src/node_modules/solidity-docgen/src/site.ts:117:51
    at Object.get [as natspec] (/home/my/src/node_modules/solidity-docgen/src/utils/memoized-getter.ts:17:19)
    at lookupProperty (/home/my/src/node_modules/handlebars/lib/handlebars/runtime.js:130:26)
    at Object.eval (eval at createFunctionContext (/home/my/src/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js:265:23), <anonymous>:16:64)

We believe it is due to ///@inheritdoc and can be reproduced with the following minimal example:

ImportedAs.sol

pragma solidity ^0.8.10;

Lib.sol

pragma solidity ^0.8.10;

import "./ImportedAs.sol" as ImportedAs;

Root.sol

pragma solidity ^0.8.10;

import {ImportedAs} from "./Lib.sol";

contract A {
   function f() internal virtual {}
}

contract B is A {
  ///@inheritdoc A
  function f() internal override {}
}
frangio commented 1 year ago

Thanks. This should be fixed in the latest version (beta.32).

lnist commented 1 year ago

Thanks! it works now.