From ca4db58d832fd1ba026ee09b442b94a7660ebb25 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 18 Jan 2019 17:52:44 -0500 Subject: [PATCH] Declare parameters of a function with their own spans --- src/Data/Syntax/Declaration.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index c1e8d5bff..d2b8aece1 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -29,16 +29,19 @@ instance Diffable Function where -- TODO: How should we represent function types, where applicable? instance Evaluatable Function where - eval _ _ Function{..} = do + eval eval _ Function{..} = do name <- maybeM (throwNoNameError functionName) (declaredName functionName) span <- ask @Span associatedScope <- declareFunction name span ScopeGraph.Function params <- withScope associatedScope . for functionParameters $ \paramNode -> do param <- maybeM (throwNoNameError paramNode) (declaredName paramNode) + -- TODO: Come up with an easier way to fetch the child node span instead of evaling it. + _ <- eval paramNode + paramSpan <- get @Span -- TODO: This might be a motivation for a typeclass for `declarationKind` since we -- sometimes create declarations for our children. - param <$ declare (Declaration param) Default span ScopeGraph.Parameter Nothing + param <$ declare (Declaration param) Default paramSpan ScopeGraph.Parameter Nothing addr <- lookupDeclaration (Declaration name) v <- function name params functionBody associatedScope