Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit daacddc

Browse files
author
Patrick Thomson
authored
Merge branch 'master' into php-strict-equal-assignment
2 parents 8a6737b + d147bb8 commit daacddc

File tree

83 files changed

+936
-637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+936
-637
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
test/fixtures linguist-vendored
33
test/repos linguist-vendored
44
vendor linguist-vendored
5+
*.protobuf.bin binary

.hlint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# Conveniences
6868
- warning: {lhs: maybe a pure, rhs: maybeM a, name: Use maybeM}
6969
- warning: {lhs: either (const a) id, rhs: fromRight a, name: use fromRight}
70-
- warning: {lhs: either id (const a), rhs: fromLeft a, name: use fromRight}
70+
- warning: {lhs: either id (const a), rhs: fromLeft a, name: use fromLeft}
7171

7272
# Applicative style
7373
- warning: {lhs: f <$> pure a <*> b, rhs: f a <$> b, name: Avoid redundant pure}

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ script:
3737
- cabal new-build
3838
- cabal new-run semantic:test
3939
- cabal new-run semantic-core:spec
40+
- cabal new-run semantic-core:doctest
4041
# parse-examples is disabled because it slaughters our CI
4142
# - cabal new-run semantic:parse-examples
4243

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
99

10+
We're happy to accept code and documentation contributions, as well as issues suggesting new features, asking questions about how things work, or generally about what we're trying to accomplish! However, we are not opening up the code review process to the public. PRs should _only_ be reviewed by one of the project maintainers. Therefore, we ask that you refrain from leaving approvals or change requests on in-progress pull requests, as spurious reviews make it difficult to discern which patches are truly ready for integration.
11+
1012
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE.md).
1113

1214
Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
@@ -28,6 +30,8 @@ Here are a few things you can do that will increase the likelihood of your pull
2830
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
2931
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
3032

33+
Unless you are a member of the Semantic team or a code owner, we ask that you refrain from leaving approvals or change requests on in-progress pull requests, as spurious reviews make it difficult to discern which patches are truly ready for integration.
34+
3135
Please be aware that contributions to Semantic may multiple cycles of code review—we are grateful for all community involvement, but because Semantic powers real systems, we must maintain a high standard of code quality. For reasons of compatibility with production uses of Semantic within GitHub, we may also reject or require modifications to changes that would affect these systems. We may also reject patches that don't fit with our vision of the project; should this be the case, we will be clear about our rationale.
3236

3337
## Resources

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,20 @@ Available options:
9696

9797
## Development
9898

99+
`semantic` requires at least GHC 8.6.4 and Cabal 2.4. We strongly recommend using [`ghcup`][ghcup] to sandbox GHC versions, as GHC packages installed through your OS's package manager may not install statically-linked versions of the GHC boot libraries.
100+
99101
We use `cabal's` [Nix-style local builds][nix] for development. To get started quickly:
100102

101103
```bash
102104
git clone git@github.com:github/semantic.git
103105
cd semantic
104-
git submodule sync --recursive && git submodule update --init --recursive --force
105-
cabal new-update
106+
script/bootstrap
106107
cabal new-build
107108
cabal new-test
108109
cabal new-run semantic -- --help
109110
```
110111

111-
`semantic` requires at least GHC 8.6.4 and Cabal 2.4. We recommend using [`ghcup`][ghcup] to sandbox GHC versions. `stack` as a build tool is not officially supported; there is an unofficial [`stack.yaml`](https://gist.github.com/jkachmar/f200caee83280f1f25e9cfa2dd2b16bb) available, though we cannot make guarantees as to its stability.
112+
`stack` as a build tool is not officially supported; there is an unofficial [`stack.yaml`](https://gist.github.com/jkachmar/f200caee83280f1f25e9cfa2dd2b16bb) available, though we cannot make guarantees as to its stability.
112113

113114
[nix]: https://www.haskell.org/cabal/users-guide/nix-local-build-overview.html
114115
[stackage]: https://stackage.org

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packages: . semantic-core
1+
packages: . semantic-core semantic-python
22

33
jobs: $ncpus
44

script/bootstrap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
git submodule sync --recursive && git submodule update --init --recursive --force
4+
cabal new-update

semantic-core/semantic-core.cabal

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ cabal-version: 2.4
33
name: semantic-core
44
version: 0.0.0.0
55
synopsis: Semantic core intermediate language
6-
-- description:
7-
homepage: https://github.com/github/semantic-core
8-
-- bug-reports:
6+
description: Core intermediate language for program analysis using abstract definitional interpretation.
7+
homepage: https://github.com/github/semantic/tree/master/semantic-core#readme
8+
bug-reports: https://github.com/github/semantic/issues
99
license: MIT
1010
license-file: LICENSE
11-
author: Rob Rix
12-
maintainer: robrix@github.com
13-
-- copyright:
11+
author: The Semantic authors
12+
maintainer: opensource+semantic@github.com
13+
copyright: (c) 2019 GitHub, Inc.
1414
category: Language
1515
build-type: Simple
16+
stability: alpha
1617
extra-source-files: README.md
1718

1819
tested-with: GHC == 8.6.4
@@ -46,14 +47,24 @@ library
4647
, prettyprinter-ansi-terminal ^>= 1.1.1
4748
, recursion-schemes ^>= 5.1
4849
, semigroupoids ^>= 5.3
50+
, text ^>= 1.2.3.1
4951
, transformers ^>= 0.5.6
5052
, trifecta ^>= 2
5153
, unordered-containers ^>= 0.2.10
5254
hs-source-dirs: src
5355
default-language: Haskell2010
54-
ghc-options: -Weverything -Wno-missing-local-signatures -Wno-missing-import-lists -Wno-implicit-prelude -Wno-safe -Wno-unsafe -Wno-name-shadowing -Wno-monomorphism-restriction -Wno-missed-specialisations -Wno-all-missed-specialisations
55-
if (impl(ghc >= 8.6))
56-
ghc-options: -Wno-star-is-type
56+
ghc-options:
57+
-Weverything
58+
-Wno-missing-local-signatures
59+
-Wno-missing-import-lists
60+
-Wno-implicit-prelude
61+
-Wno-safe
62+
-Wno-unsafe
63+
-Wno-name-shadowing
64+
-Wno-monomorphism-restriction
65+
-Wno-missed-specialisations
66+
-Wno-all-missed-specialisations
67+
-Wno-star-is-type
5768

5869
test-suite doctest
5970
type: exitcode-stdio-1.0

semantic-core/src/Analysis/Concrete.hs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE FlexibleContexts, FlexibleInstances, GeneralizedNewtypeDeriving, LambdaCase, MultiParamTypeClasses, NamedFieldPuns, RecordWildCards, TypeApplications, TypeOperators, UndecidableInstances #-}
1+
{-# LANGUAGE FlexibleContexts, FlexibleInstances, LambdaCase, MultiParamTypeClasses, NamedFieldPuns, OverloadedStrings, RecordWildCards, TypeOperators, UndecidableInstances #-}
22
module Analysis.Concrete
33
( Concrete(..)
44
, concrete
@@ -29,6 +29,7 @@ import Data.Loc
2929
import qualified Data.Map as Map
3030
import Data.Monoid (Alt(..))
3131
import Data.Name
32+
import Data.Text (Text, pack)
3233
import Prelude hiding (fail)
3334

3435
type Precise = Int
@@ -41,7 +42,7 @@ data Concrete
4142
= Closure Loc Name Core.Core Precise
4243
| Unit
4344
| Bool Bool
44-
| String String
45+
| String Text
4546
| Obj Frame
4647
deriving (Eq, Ord, Show)
4748

@@ -60,7 +61,7 @@ type Heap = IntMap.IntMap Concrete
6061

6162
-- | Concrete evaluation of a term to a value.
6263
--
63-
-- >>> snd (concrete [File (Loc "bool" emptySpan) (Core.Bool True)])
64+
-- >>> map fileBody (snd (concrete [File (Loc "bool" emptySpan) (Core.Bool True)]))
6465
-- [Right (Bool True)]
6566
concrete :: [File Core.Core] -> (Heap, [File (Either (Loc, String) Concrete)])
6667
concrete
@@ -184,28 +185,32 @@ heapValueGraph h = heapGraph (const id) (const fromAddr) h
184185
heapAddressGraph :: Heap -> G.Graph (EdgeType, Precise)
185186
heapAddressGraph = heapGraph (\ addr v -> (Value v, addr)) (fmap G.vertex . (,) . either Edge Slot)
186187

187-
addressStyle :: Heap -> G.Style (EdgeType, Precise) String
188+
addressStyle :: Heap -> G.Style (EdgeType, Precise) Text
188189
addressStyle heap = (G.defaultStyle vertex) { G.edgeAttributes }
189-
where vertex (_, addr) = maybe (show addr <> " = ?") (((show addr <> " = ") <>) . fromConcrete) (IntMap.lookup addr heap)
190+
where vertex (_, addr) = pack (show addr) <> " = " <> maybe "?" fromConcrete (IntMap.lookup addr heap)
190191
edgeAttributes _ (Slot name, _) = ["label" G.:= fromName name]
191192
edgeAttributes _ (Edge Core.Import, _) = ["color" G.:= "blue"]
192193
edgeAttributes _ (Edge Core.Lexical, _) = ["color" G.:= "green"]
193194
edgeAttributes _ _ = []
194195
fromConcrete = \case
195196
Unit -> "()"
196-
Bool b -> show b
197-
String s -> show s
197+
Bool b -> pack $ show b
198+
String s -> pack $ show s
198199
Closure (Loc p (Span s e)) n _ _ -> "\\\\ " <> fromName n <> " [" <> p <> ":" <> showPos s <> "-" <> showPos e <> "]"
199200
Obj _ -> "{}"
200-
showPos (Pos l c) = show l <> ":" <> show c
201+
showPos (Pos l c) = pack (show l) <> ":" <> pack (show c)
201202
fromName (User s) = s
202203
fromName (Gen sym) = fromGensym sym
203-
fromName (Path p) = show p
204+
fromName (Path p) = pack $ show p
204205
fromGensym (Root s) = s
205-
fromGensym (ss :/ (s, i)) = fromGensym ss <> "." <> s <> show i
206+
fromGensym (ss :/ (s, i)) = fromGensym ss <> "." <> s <> pack (show i)
206207

207208
data EdgeType
208209
= Edge Core.Edge
209210
| Slot Name
210211
| Value Concrete
211212
deriving (Eq, Ord, Show)
213+
214+
215+
-- $setup
216+
-- >>> :seti -XOverloadedStrings

semantic-core/src/Analysis/Eval.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE FlexibleContexts, GeneralizedNewtypeDeriving, LambdaCase, RankNTypes, RecordWildCards #-}
1+
{-# LANGUAGE FlexibleContexts, LambdaCase, OverloadedStrings, RankNTypes, RecordWildCards #-}
22
module Analysis.Eval
33
( eval
44
, prog1
@@ -21,6 +21,7 @@ import Data.Functor
2121
import Data.Loc
2222
import Data.Maybe (fromJust)
2323
import Data.Name
24+
import Data.Text (Text)
2425
import GHC.Stack
2526
import Prelude hiding (fail)
2627

@@ -207,8 +208,8 @@ data Analysis address value m = Analysis
207208
, unit :: m value
208209
, bool :: Bool -> m value
209210
, asBool :: value -> m Bool
210-
, string :: String -> m value -- FIXME: Text
211-
, asString :: value -> m String
211+
, string :: Text -> m value
212+
, asString :: value -> m Text
212213
, frame :: m value
213214
, edge :: Edge -> address -> m ()
214215
, (...) :: forall a . address -> m a -> m a

0 commit comments

Comments
 (0)