github / semantic

Parsing, analyzing, and comparing source code across many languages
8.94k stars 453 forks source link

Build Error Compiling Python #648

Closed rteehas closed 3 years ago

rteehas commented 3 years ago

Hi, I've been attempting to compile a version of semantic based on an older commit to replicate this project (https://github.com/danielzuegner/code-transformer#21-semantic). I seem to be getting an error on compiling the Python ScopeGraph. I've tried compiling the 34ea0d1dd6 and c872660ffc versions, which both appear to have ghc checks passing on GitHub. This is the full stack trace that I get for the error when running cabal v2-build:

[6 of 8] Compiling Language.Python.ScopeGraph ( src/Language/Python/ScopeGraph.hs, /Users/rteehan/code_clip/semantic/dist-newstyle/build/x86_64-osx/ghc-8.8.1/semantic-python-0.0.0.0/build/Language/Python/ScopeGraph.o )

src/Language/Python/ScopeGraph.hs:227:19: error:
    • Couldn't match type ‘(:+:) Py.ElifClause Py.ElseClause Loc’
                     with ‘Loc’
      Expected type: [Loc]
        Actual type: [(:+:) Py.ElifClause Py.ElseClause Loc]
    • In the first argument of ‘scopeGraph’, namely ‘body’
      In the first argument of ‘(<>)’, namely ‘scopeGraph body’
      In the second argument of ‘(<>)’, namely
        ‘scopeGraph body <> foldMap scopeGraph alternative’
    |
227 |     <> scopeGraph body
    |                   ^^^^

src/Language/Python/ScopeGraph.hs:228:27: error:
    • Couldn't match type ‘Loc’ with ‘t0 Loc’
      Expected type: Py.Expression (t0 Loc)
        Actual type: Py.Expression Loc
    • In the second argument of ‘foldMap’, namely ‘alternative’
      In the second argument of ‘(<>)’, namely
        ‘foldMap scopeGraph alternative’
      In the second argument of ‘(<>)’, namely
        ‘scopeGraph body <> foldMap scopeGraph alternative’
    |
228 |     <> foldMap scopeGraph alternative
    |                           ^^^^^^^^^^^

src/Language/Python/ScopeGraph.hs:254:40: error:
    • Couldn't match expected type ‘(:+:)
                                      Py.DottedName Py.RelativeImport Loc’
                  with actual type ‘[a0]’
    • In the pattern: []
      In the pattern:
        Py.ImportFromStatement _
                               []
                               (L1 (Py.DottedName _ names))
                               (Just (Py.WildcardImport _ _))
      In an equation for ‘scopeGraph’:
          scopeGraph
            (Py.ImportFromStatement _
                                    []
                                    (L1 (Py.DottedName _ names))
                                    (Just (Py.WildcardImport _ _)))
            = do let toName (Py.Identifier _ name) = ...
                 complete <* newEdge Import (toName <$> names)
    |
254 |   scopeGraph (Py.ImportFromStatement _ [] (L1 (Py.DottedName _ names)) (Just (Py.WildcardImport _ _))) = do
    |                                        ^^

src/Language/Python/ScopeGraph.hs:254:44: error:
    • Couldn't match expected type ‘[(:+:)
                                       Py.AliasedImport Py.DottedName Loc]’
                  with actual type ‘(:+:) Py.DottedName g0 a1’
    • In the pattern: L1 (Py.DottedName _ names)
      In the pattern:
        Py.ImportFromStatement _
                               []
                               (L1 (Py.DottedName _ names))
                               (Just (Py.WildcardImport _ _))
      In an equation for ‘scopeGraph’:
          scopeGraph
            (Py.ImportFromStatement _
                                    []
                                    (L1 (Py.DottedName _ names))
                                    (Just (Py.WildcardImport _ _)))
            = do let toName (Py.Identifier _ name) = ...
                 complete <* newEdge Import (toName <$> names)
    |
254 |   scopeGraph (Py.ImportFromStatement _ [] (L1 (Py.DottedName _ names)) (Just (Py.WildcardImport _ _))) = do
    |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Language/Python/ScopeGraph.hs:257:55: error:
    • Couldn't match expected type ‘(:+:)
                                      Py.DottedName Py.RelativeImport Loc’
                  with actual type ‘[a2]’
    • In the pattern: []
      In the pattern:
        Py.ImportFromStatement _ [] (L1 (Py.DottedName _ _)) Nothing
      In an equation for ‘scopeGraph’:
          scopeGraph
            impossibleTerm@(Py.ImportFromStatement _
                                                   []
                                                   (L1 (Py.DottedName _ _))
                                                   Nothing)
            = todo impossibleTerm
    |
257 |   scopeGraph impossibleTerm@(Py.ImportFromStatement _ [] (L1 (Py.DottedName _ _)) Nothing) =
    |                                                       ^^

src/Language/Python/ScopeGraph.hs:257:59: error:
    • Couldn't match expected type ‘[(:+:)
                                       Py.AliasedImport Py.DottedName Loc]’
                  with actual type ‘(:+:) Py.DottedName g1 p0’
    • In the pattern: L1 (Py.DottedName _ _)
      In the pattern:
        Py.ImportFromStatement _ [] (L1 (Py.DottedName _ _)) Nothing
      In an equation for ‘scopeGraph’:
          scopeGraph
            impossibleTerm@(Py.ImportFromStatement _
                                                   []
                                                   (L1 (Py.DottedName _ _))
                                                   Nothing)
            = todo impossibleTerm
    |
257 |   scopeGraph impossibleTerm@(Py.ImportFromStatement _ [] (L1 (Py.DottedName _ _)) Nothing) =

My GHC version is 8.8.1 and my Cabal version is 3.0.0.0.

aneeshjain commented 3 years ago

Ive been having the exact same issue as well. Did you happen to find a workaround?

patrickt commented 3 years ago

You’ll need to upgrade to GHC 8.10.1, as per the readme.