mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-25 09:17:27 +03:00
fix issue with DFO instantiation tracking of path info
This commit is contained in:
parent
03caf04271
commit
415ff70898
@ -589,6 +589,13 @@ debugDoc (p :< l) = show p : case l of
|
||||
Group r -> debugDoc r
|
||||
_ -> []
|
||||
|
||||
leafPaths :: Path p => Doc e p -> [p]
|
||||
leafPaths (p :< d) = map (Path.extend p) $ case d of
|
||||
Append a b -> leafPaths a ++ leafPaths b
|
||||
Nest _ r -> leafPaths r
|
||||
Group r -> leafPaths r
|
||||
_ -> [Path.root]
|
||||
|
||||
-- various instances
|
||||
|
||||
instance Bifunctor L where
|
||||
|
@ -368,7 +368,7 @@ view ref t = go no View.low t where
|
||||
let
|
||||
Symbol.Symbol _ name view = op fn
|
||||
(taken, remaining) = splitAt (View.arity view) args
|
||||
fmt (child,path) = (\p -> D.sub' path (go (fn ==) p child), path)
|
||||
fmt (child,path) = (\p -> go (fn ==) p child, path)
|
||||
applied = fromMaybe unsaturated (View.instantiate view fnP name (map fmt taken))
|
||||
unsaturated = D.sub' fnP $ go no View.high fn
|
||||
in
|
||||
|
@ -39,11 +39,18 @@ tests = withResource Common.node (\_ -> pure ()) $ \node -> testGroup "Term"
|
||||
, testCase "hash cycles" $ assertEqual "pingpong"
|
||||
(hash pingpong1)
|
||||
(hash pingpong2)
|
||||
, testCase "infix-rendering" $ node >>= \(_,symbol) ->
|
||||
, testCase "infix-rendering (1)" $ node >>= \(_,symbol) ->
|
||||
let t = num 1 `plus` num 1
|
||||
in assertEqual "+"
|
||||
"1 + 1"
|
||||
(Doc.formatText (Width 80) (view symbol t))
|
||||
, testCase "infix-rendering (2)" $ node >>= \(_,symbol) ->
|
||||
do
|
||||
t <- pure $ num 1 `plus` num 1
|
||||
let d = view symbol t
|
||||
assertEqual "path sanity check"
|
||||
[Fn,Arg]
|
||||
(head $ Doc.leafPaths d)
|
||||
]
|
||||
|
||||
-- various unison terms, useful for testing
|
||||
|
Loading…
Reference in New Issue
Block a user