Skip to content

Commit

Permalink
remove alias cycle detection (not needed anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Nov 29, 2024
1 parent a6bc806 commit 64e3813
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3266,17 +3266,7 @@ checkAliasDef def@AliasDef {..} = do
aliasId <- gets (^?! scopeLocalSymbols . at (a ^. aliasDefName) . _Just . S.nameId)
asName <- checkName (a ^. aliasDefAsName)
modify' (set (scoperAlias . at aliasId) (Just asName))
checkLoop aliasId
registerAlias aliasId asName
where
checkLoop :: NameId -> Sem r ()
checkLoop = evalState (mempty :: HashSet NameId) . go
where
go :: (Members '[State (HashSet NameId), Error ScoperError, State ScoperState] s) => NameId -> Sem s ()
go i = do
whenM (gets (HashSet.member i)) (throw (ErrAliasCycle (AliasCycle a)))
modify' (HashSet.insert i)
whenJustM (gets (^? scoperAlias . at i . _Just . preSymbolName . S.nameId)) go

reserveAliasDef ::
(Members '[Error ScoperError, Reader ScopeParameters, State Scope, State ScoperState, InfoTableBuilder, Reader InfoTable, NameIdGen, State ScoperSyntax, Reader BindingStrategy] r) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ data ScoperError
| ErrMissingArgs MissingArgs
| ErrPrecedenceInconsistency PrecedenceInconsistencyError
| ErrIncomparablePrecedences IncomaprablePrecedences
| ErrAliasCycle AliasCycle
| ErrInvalidRangeNumber InvalidRangeNumber
| ErrWrongDefaultValue WrongDefaultValue
| ErrUnsupported Unsupported
Expand Down Expand Up @@ -104,7 +103,6 @@ instance ToGenericError ScoperError where
ErrMissingArgs e -> genericError e
ErrPrecedenceInconsistency e -> genericError e
ErrIncomparablePrecedences e -> genericError e
ErrAliasCycle e -> genericError e
ErrInvalidRangeNumber e -> genericError e
ErrWrongDefaultValue e -> genericError e
ErrUnsupported e -> genericError e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,28 +1019,6 @@ instance ToGenericError IncomaprablePrecedences where
i :: Interval
i = getLoc _incomparablePrecedencesName1

newtype AliasCycle = AliasCycle
{ _aliasCycleDef :: AliasDef 'Parsed
}
deriving stock (Show)

instance ToGenericError AliasCycle where
genericError AliasCycle {..} = do
opts <- fromGenericOptions <$> ask
let msg =
"The definition of"
<+> ppCode opts (_aliasCycleDef ^. aliasDefName)
<+> "creates an alias cycle."
return
GenericError
{ _genericErrorLoc = i,
_genericErrorMessage = mkAnsiText msg,
_genericErrorIntervals = [i]
}
where
i :: Interval
i = getLoc _aliasCycleDef

newtype WrongDefaultValue = WrongDefaultValue
{ _wrongDefaultValue :: SigArg 'Parsed
}
Expand Down
4 changes: 2 additions & 2 deletions src/Juvix/Compiler/Core/Transformation/Optimize/Inlining.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ convertNode inlineDepth nonRecSyms md = dmapL go
node
_
| HashSet.member _identSymbol nonRecSyms
&& isInlineableLambda inlineDepth md bl def
&& length args >= argsNum ->
&& length args >= argsNum
&& isInlineableLambda inlineDepth md bl def ->
mkApps def args
_ ->
node
Expand Down
5 changes: 0 additions & 5 deletions test/Scope/Negative.hs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ scoperErrorTests =
$(mkRelDir ".")
$(mkRelFile "PrecedenceInconsistency.juvix")
$ wantsError ErrPrecedenceInconsistency,
negTest
"Alias cycle"
$(mkRelDir ".")
$(mkRelFile "AliasCycle.juvix")
$ wantsError ErrAliasCycle,
negTest
"Invalid range number in iterator definition"
$(mkRelDir ".")
Expand Down
5 changes: 0 additions & 5 deletions tests/negative/AliasCycle.juvix

This file was deleted.

0 comments on commit 64e3813

Please sign in to comment.