Skip to content

Commit

Permalink
Semantic: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Apr 30, 2024
1 parent bb88577 commit 31407ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/semantic/expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ export const checkForExpr = (forExpr: ForExpr, ctx: Context): void => {

const iterableType = [iter, iterable]
.map(t => extractConcreteSupertype(forExpr.expr.type!, t.identifier, ctx))
.filter(t => !!t)
.at(0)
.find(t => !!t)
if (iterableType) {
assert(iterableType!.kind === 'vid-type', `iterable type is ${iterableType!.kind}`)
const itemType = (<VidType>iterableType).typeArgs.at(0)
Expand Down
6 changes: 4 additions & 2 deletions src/semantic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,10 @@ const checkTraitDef = (traitDef: TraitDef, ctx: Context) => {
const checkImplDef = (implDef: ImplDef, ctx: Context) => {
if (!implDef.rel) {
const rel = ctx.impls.find(i => i.instanceDef === implDef)
assert(!!rel)
implDef.rel = rel!
// error is handled when preparing ctx.impls
if (!rel) return

implDef.rel = rel
}

const module = ctx.moduleStack.at(-1)!
Expand Down

0 comments on commit 31407ba

Please sign in to comment.