Skip to content

Commit

Permalink
Merge pull request #184 from uqbar-project/fix-#180-#35-#36-should-no…
Browse files Browse the repository at this point in the history
…t-get-an-instance

Fix #180 #35 #36 should not get an instance
  • Loading branch information
Juancete authored Nov 3, 2023
2 parents 36dcbe7 + 2ffdba1 commit 1b8218f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/interpreter/runtimeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { WOLLOK_BASE_PACKAGE, WOLLOK_EXTRA_STACK_TRACE_HEADER } from '../constan
import { v4 as uuid } from 'uuid'
import { getPotentiallyUninitializedLazy } from '../decorators'
import { get, is, last, List, match, raise, when } from '../extensions'
import { Assignment, Body, Catch, Describe, Environment, Entity, Expression, Id, If, Literal, LiteralValue, Method, Module, Name, New, Node, Package, Program, Reference, Return, Self, Send, Singleton, Super, Test, Throw, Try, Variable } from '../model'
import { Assignment, Body, Catch, Describe, Environment, Entity, Expression, Id, If, Literal, LiteralValue, Method, Module, Name, New, Node, Package, Program, Reference, Return, Self, Send, Singleton, Super, Test, Throw, Try, Variable, Class } from '../model'
import { Interpreter } from './interpreter'

const { isArray } = Array
Expand Down Expand Up @@ -488,6 +488,12 @@ export class Evaluation {

const target = node.instantiated.target ?? raise(new Error(`Could not resolve reference to instantiated module ${node.instantiated.name}`))

const name = node.instantiated.name

Check warning on line 492 in src/interpreter/runtimeModel.ts

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
if (!target.is(Class)) raise(new Error(`${name} is not a class, you cannot generate instances of a ${target?.kind}`))

if (target.isAbstract) raise(new Error(`${name} is an abstract class, you cannot generate instances`))

return yield* this.instantiate(target, args)
}

Expand Down

0 comments on commit 1b8218f

Please sign in to comment.