Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libsolidity/codegen/ExpressionCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration) ||
dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration) ||
dynamic_cast<ErrorDefinition const*>(_memberAccess.annotation().referencedDeclaration) ||
dynamic_cast<EventDefinition const*>(_memberAccess.annotation().referencedDeclaration) ||
category == Type::Category::TypeType ||
category == Type::Category::Module,
""
Expand Down
1 change: 1 addition & 0 deletions libsolidity/codegen/ir/IRGeneratorForStatements.cpp
Copy link
Collaborator

@cameel cameel Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a related error message in the parser that is missing events as well:

fatalParserError(7858_error, "Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition.");

It should also mention UDVTs, but I'd recommend just replacing "struct/enum" with a catch-all "user-defined type" instead.

Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,7 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration) ||
dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration) ||
dynamic_cast<ErrorDefinition const*>(_memberAccess.annotation().referencedDeclaration) ||
dynamic_cast<EventDefinition const*>(_memberAccess.annotation().referencedDeclaration) ||
category == Type::Category::TypeType ||
category == Type::Category::Module,
""
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more complete coverage, we should add other types of tests here:

And I suspect we're missing this coverage for imported errors as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I think ABI/AST tests are not multi-file but you can work around it by just having the file import itself as a module.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No contract is being imported here. event_emit_from_module_via_member_access.sol would be a more accurate name.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
==== Source: a ====
event Transfer(address indexed _from, address indexed _to, uint256 _value);
==== Source: b ====
import * as Test2 from "a";
Comment on lines +1 to +4
Copy link
Collaborator

@cameel cameel Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit clearer naming so that it's more obvious at a glance what is a file, what is a module, etc.

Suggested change
==== Source: a ====
event Transfer(address indexed _from, address indexed _to, uint256 _value);
==== Source: b ====
import * as Test2 from "a";
==== Source: A.sol ====
event Transfer(address indexed _from, address indexed _to, uint256 _value);
==== Source: B.sol ====
import * as M from "A.sol";


contract A {
function returnAddress() external {
emit Test2.Transfer(address(11), address(12), 13);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have coverage for the M.C.Transfer and M1.M2.Transfer cases (where C is a contract)?

And same for errors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

}
}
// ----
// returnAddress() ->
// ~ emit Transfer(address,address,uint256): #0x0b, #0x0c, 0x0d