From a6657cc6791b0d6504430792c2785fc4278efc4b Mon Sep 17 00:00:00 2001 From: joshvera Date: Thu, 13 Dec 2018 13:14:33 -0500 Subject: [PATCH] Redeclare Instance members within an object frame in New Co-Authored-By: Rick Winfrey --- src/Data/Syntax/Expression.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Data/Syntax/Expression.hs b/src/Data/Syntax/Expression.hs index 6ebccfa0b..5abf83c9f 100644 --- a/src/Data/Syntax/Expression.hs +++ b/src/Data/Syntax/Expression.hs @@ -642,10 +642,16 @@ instance Evaluatable New where objectFrame <- newFrame objectScope (Map.singleton Superclass $ Map.singleton assocScope classFrame) objectVal <- object objectFrame + classScope <- scopeLookup classFrame + instanceMembers <- relationsOfScope classScope Instance + void . withScopeAndFrame objectFrame $ do + for_ instanceMembers $ \Data{..} -> do + declare dataDeclaration dataRelation dataSpan dataAssociatedScope + let constructorName = Name.name "constructor" reference (Reference constructorName) (Declaration constructorName) - constructor <- deref =<< lookupDeclaration (Declaration $ constructorName) + constructor <- deref =<< lookupDeclaration (Declaration constructorName) args <- traverse eval arguments call constructor (objectVal : args)