Skip to content

Commit 3346deb

Browse files
committed
Look up type again if accessing incomplete structs.
If a struct was forward-declared, then completed later, we previously didn't always allow accessing fields on that struct. It depended on whether typedefs were involved and what order the declarations appeared in. This commit ensures that we always find the right type declaration, if it's in scope at the time of use.
1 parent d1dc2e1 commit 3346deb

File tree

1 file changed

+5
-0
lines changed
  • src/Language/Rust/Corrode

1 file changed

+5
-0
lines changed

src/Language/Rust/Corrode/C.md

+5
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,11 @@ interpretExpr _ expr@(CMember obj ident deref node) = do
18251825
obj' <- interpretExpr True $ if deref then CUnary CIndOp obj node else obj
18261826
fields <- case resultType obj' of
18271827
IsStruct _ fields -> return fields
1828+
IsIncomplete tyIdent -> do
1829+
(_, struct) <- getIdent (StructIdent tyIdent)
1830+
case struct of
1831+
Just (_, IsStruct _ fields) -> return fields
1832+
_ -> badSource expr "member access of incomplete type"
18281833
_ -> badSource expr "member access of non-struct"
18291834
let field = identToString ident
18301835
ty <- case lookup field fields of

0 commit comments

Comments
 (0)