1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 05:42:26 +03:00

remove alias cycle detection (not needed anymore)

This commit is contained in:
Lukasz Czajka 2024-11-29 18:53:01 +01:00 committed by Łukasz Czajka
parent a6bc806799
commit 64e3813d36
6 changed files with 2 additions and 46 deletions

View File

@ -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) =>

View File

@ -51,7 +51,6 @@ data ScoperError
| ErrMissingArgs MissingArgs
| ErrPrecedenceInconsistency PrecedenceInconsistencyError
| ErrIncomparablePrecedences IncomaprablePrecedences
| ErrAliasCycle AliasCycle
| ErrInvalidRangeNumber InvalidRangeNumber
| ErrWrongDefaultValue WrongDefaultValue
| ErrUnsupported Unsupported
@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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 ".")

View File

@ -1,5 +0,0 @@
module AliasCycle;
syntax alias x1 := x2;
syntax alias x2 := x3;
syntax alias x3 := x1;