Skip to content

Commit

Permalink
Missing typos
Browse files Browse the repository at this point in the history
  • Loading branch information
PalumboN committed Nov 26, 2023
1 parent bf022a3 commit 95e37df
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
18 changes: 9 additions & 9 deletions src/typeSystem/typeVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export function newTypeVariables(env: Environment): Map<Node, TypeVariable> {
return tVars
}

export function newSynteticTVar(node?: Node): TypeVariable {
return doNewTVarFor(node?.copy() ?? Closure({ code: 'Param type' })) // Using new closure as syntetic node. Is good enough? No.
.beSyntetic()
export function newSyntheticTVar(node?: Node): TypeVariable {
return doNewTVarFor(node?.copy() ?? Closure({ code: 'Param type' })) // Using new closure as synthetic node. Is it good enough? Not for logging.
.beSynthetic()
}

export function typeVariableFor(node: Node): TypeVariable {
Expand All @@ -27,7 +27,7 @@ function newTVarFor(node: Node) {
let annotatedVar = newTVar // By default, annotations reference the same tVar
if (node.is(Method)) {
const parameters = node.parameters.map(p => createTypeVariables(p)!)
annotatedVar = newSynteticTVar(node) // But for methods, annotations reference to return tVar
annotatedVar = newSyntheticTVar(node) // But for methods, annotations reference to return tVar
newTVar.setType(new WollokMethodType(annotatedVar, parameters, annotatedVariableMap(node)), false)
}
if (node.is(Singleton) && node.isClosure()) {
Expand Down Expand Up @@ -260,7 +260,7 @@ export class TypeVariable {
atParam(name: string): TypeVariable { return this.type().atParam(name) }
newInstance(name: string): TypeVariable {
return this.cachedParams.get(name) ??
this.cachedParams.set(name, newSynteticTVar(this.node)).get(name)!
this.cachedParams.set(name, newSyntheticTVar(this.node)).get(name)!
}
instanceFor(instance: TypeVariable, send?: TypeVariable, name?: string): TypeVariable { return this.type().instanceFor(instance, send, name) || this }

Expand Down Expand Up @@ -344,7 +344,7 @@ export class TypeVariable {
this.hasProblems = true
}

beSyntetic(): this {
beSynthetic(): this {
this.synthetic = true
return this
}
Expand Down Expand Up @@ -457,8 +457,8 @@ function annotatedWollokType(annotatedType: string, node: Node): WollokType {
function parseAnnotatedClosure(annotatedType: string, node: Node) {
const [params, returnTypeName] = annotatedType.slice(1, -1).split('=>')
const parameters = params.trim().slice(1, -1).split(',').map(_ => _.trim()).filter(_ => _ /* clean empty arguments */)
const parametersTVar = parameters.map(_ => newSynteticTVar(node).setType(annotatedWollokType(_, node)))
const returnTypeTVar = newSynteticTVar(node).setType(annotatedWollokType(returnTypeName.trim(), node))
const parametersTVar = parameters.map(_ => newSyntheticTVar(node).setType(annotatedWollokType(_, node)))
const returnTypeTVar = newSyntheticTVar(node).setType(annotatedWollokType(returnTypeName.trim(), node))
return new WollokClosureType(returnTypeTVar, parametersTVar, Closure({ code: annotatedType }))
}

Expand All @@ -478,7 +478,7 @@ function isParameterName(name: string, node: Node) {
// TODO: Support many variables
function annotatedVariableMap(n: Node) {
const varName = annotatedVariableName(n)
if (varName) return { [varName]: newSynteticTVar(n) }
if (varName) return { [varName]: newSyntheticTVar(n) }
return {}
}

Expand Down
74 changes: 37 additions & 37 deletions test/typeSystem.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { should } from 'chai'
import { Closure, Environment, Literal, Method, Name, Parameter, Self, Send, Singleton } from '../src'
import { bindReceivedMessages, propagateMaxTypes, propagateMinTypes } from '../src/typeSystem/constraintBasedTypeSystem'
import { newSynteticTVar, TypeVariable, typeVariableFor } from '../src/typeSystem/typeVariables'
import { newSyntheticTVar, TypeVariable, typeVariableFor } from '../src/typeSystem/typeVariables'
import { AtomicType, RETURN, WollokAtomicType, WollokClosureType, WollokMethodType, WollokParameterType, WollokParametricType } from '../src/typeSystem/wollokTypes'

should()
Expand All @@ -10,13 +10,13 @@ describe('Wollok Type System', () => {
let tVar: TypeVariable

beforeEach(() => {
tVar = newSynteticTVar()
tVar = newSyntheticTVar()
})

describe('Minimal types propagation', () => {

it('should propagate min types from type variable to supertypes without min types', () => {
const supertype = newSynteticTVar()
const supertype = newSyntheticTVar()
tVar.addSupertype(supertype)
tVar.addMinType(stubType)

Expand All @@ -26,7 +26,7 @@ describe('Wollok Type System', () => {
})

it('should propagate min types from type variable to supertypes with other min types', () => {
const supertype = newSynteticTVar()
const supertype = newSyntheticTVar()
supertype.addMinType(otherStubType)
tVar.addSupertype(supertype)
tVar.addMinType(stubType)
Expand All @@ -37,7 +37,7 @@ describe('Wollok Type System', () => {
})

it('should not propagate min types if already exist in supertypes', () => {
const supertype = newSynteticTVar()
const supertype = newSyntheticTVar()
supertype.addMinType(stubType)
tVar.addSupertype(supertype)
tVar.addMinType(stubType)
Expand All @@ -48,7 +48,7 @@ describe('Wollok Type System', () => {
})

it('should not propagate max types', () => {
const supertype = newSynteticTVar()
const supertype = newSyntheticTVar()
tVar.addSupertype(supertype)
tVar.addMaxType(stubType)

Expand All @@ -58,7 +58,7 @@ describe('Wollok Type System', () => {
})

it('propagate to a closed type variables should report a problem', () => {
const supertype = newSynteticTVar().setType(otherStubType)
const supertype = newSyntheticTVar().setType(otherStubType)
tVar.addSupertype(supertype)
tVar.addMinType(stubType)

Expand All @@ -70,7 +70,7 @@ describe('Wollok Type System', () => {
})

it('propagate to a closed type variables with same type should not report a problem', () => {
const supertype = newSynteticTVar().setType(stubType)
const supertype = newSyntheticTVar().setType(stubType)
tVar.addSupertype(supertype)
tVar.addMinType(stubType)

Expand All @@ -85,7 +85,7 @@ describe('Wollok Type System', () => {
describe('Maximal types propagation', () => {

it('should propagate max types from type variable to subtypes without max types', () => {
const subtype = newSynteticTVar()
const subtype = newSyntheticTVar()
tVar.addSubtype(subtype)
tVar.addMaxType(stubType)

Expand All @@ -95,7 +95,7 @@ describe('Wollok Type System', () => {
})

it('should propagate max types from type variable to subtypes with other max types', () => {
const subtype = newSynteticTVar()
const subtype = newSyntheticTVar()
subtype.addMaxType(otherStubType)
tVar.addSubtype(subtype)
tVar.addMaxType(stubType)
Expand All @@ -106,7 +106,7 @@ describe('Wollok Type System', () => {
})

it('should not propagate max types if already exist in subtypes', () => {
const subtype = newSynteticTVar()
const subtype = newSyntheticTVar()
subtype.addMaxType(stubType)
tVar.addSubtype(subtype)
tVar.addMaxType(stubType)
Expand All @@ -117,7 +117,7 @@ describe('Wollok Type System', () => {
})

it('should not propagate min types', () => {
const subtype = newSynteticTVar()
const subtype = newSyntheticTVar()
tVar.addSubtype(subtype)
tVar.addMinType(stubType)

Expand All @@ -127,7 +127,7 @@ describe('Wollok Type System', () => {
})

it('propagate to a closed type variables should report a problem', () => {
const subtype = newSynteticTVar().setType(otherStubType)
const subtype = newSyntheticTVar().setType(otherStubType)
tVar.addSubtype(subtype)
tVar.addMaxType(stubType)

Expand All @@ -139,7 +139,7 @@ describe('Wollok Type System', () => {
})

it('propagate to a closed type variables with same type should not report a problem', () => {
const subtype = newSynteticTVar().setType(stubType)
const subtype = newSyntheticTVar().setType(stubType)
tVar.addSubtype(subtype)
tVar.addMaxType(stubType)

Expand Down Expand Up @@ -218,14 +218,14 @@ describe('Wollok Type System', () => {
let parametricType: WollokParametricType

beforeEach(() => {
parametricType = new WollokParametricType(module, { 'param': newSynteticTVar() })
parametricType = new WollokParametricType(module, { 'param': newSyntheticTVar() })
tVar.setType(parametricType)
})

describe('should be propagated', () => {

it('To Any variable', () => {
const supertype = newSynteticTVar()
const supertype = newSyntheticTVar()
tVar.addSupertype(supertype)
propagateMinTypes(tVar)

Expand All @@ -234,8 +234,8 @@ describe('Wollok Type System', () => {

it('To param inside an equivalent type', () => {
parametricType.atParam('param').setType(stubType)
const param = newSynteticTVar()
const supertype = newSynteticTVar().setType(new WollokParametricType(module, { param }), false)
const param = newSyntheticTVar()
const supertype = newSyntheticTVar().setType(new WollokParametricType(module, { param }), false)
tVar.addSupertype(supertype)
propagateMinTypes(tVar)

Expand All @@ -245,14 +245,14 @@ describe('Wollok Type System', () => {

it('To partial params inside an equivalent type', () => {
parametricType =new WollokParametricType(module, {
'param1': newSynteticTVar(),
'param2': newSynteticTVar().setType(otherStubType),
'param3': newSynteticTVar(),
'param1': newSyntheticTVar(),
'param2': newSyntheticTVar().setType(otherStubType),
'param3': newSyntheticTVar(),
})
const param1 = newSynteticTVar().setType(stubType)
const param2 = newSynteticTVar()
const param3 = newSynteticTVar()
const supertype = newSynteticTVar().setType(new WollokParametricType(module, { param1, param2, param3 }), false)
const param1 = newSyntheticTVar().setType(stubType)
const param2 = newSyntheticTVar()
const param3 = newSyntheticTVar()
const supertype = newSyntheticTVar().setType(new WollokParametricType(module, { param1, param2, param3 }), false)
tVar.setType(parametricType)
tVar.addSupertype(supertype)
propagateMinTypes(tVar)
Expand All @@ -267,8 +267,8 @@ describe('Wollok Type System', () => {

it('Link instance type variables', () => {
tVar.atParam('param').setType(new WollokParameterType('ELEMENT_TEST'))
const innerInstance = newSynteticTVar().setType(stubType)
const instance = newSynteticTVar().setType(new WollokParametricType(module, { 'ELEMENT_TEST': innerInstance }))
const innerInstance = newSyntheticTVar().setType(stubType)
const instance = newSyntheticTVar().setType(new WollokParametricType(module, { 'ELEMENT_TEST': innerInstance }))
const newInstance = tVar.instanceFor(instance)

newInstance.should.not.be.eq(tVar) // New TVAR
Expand All @@ -277,8 +277,8 @@ describe('Wollok Type System', () => {

it('Create message type variables', () => {
const innerTVar = tVar.atParam('param').setType(new WollokParameterType('MAP_TEST'))
const instance = newSynteticTVar().setType(new WollokParametricType(module)) // Empty for parameter // Mismatche with basic types... :(
const send = newSynteticTVar() // Without send there is no instance
const instance = newSyntheticTVar().setType(new WollokParametricType(module)) // Empty for parameter // Mismatche with basic types... :(
const send = newSyntheticTVar() // Without send there is no instance
const newInstance = tVar.instanceFor(instance, send)

newInstance.should.not.be.eq(tVar) // New TVAR
Expand All @@ -287,12 +287,12 @@ describe('Wollok Type System', () => {

it('Link message type variables between them', () => {
const parameter = new WollokParameterType('MAP_TEST')
const innerType = newSynteticTVar().setType(parameter)
const otherInnerType = newSynteticTVar().setType(parameter)
const innerType = newSyntheticTVar().setType(parameter)
const otherInnerType = newSyntheticTVar().setType(parameter)
tVar.setType(new WollokParametricType(module, { innerType, otherInnerType }))

const instance = newSynteticTVar().setType(new WollokParametricType(module)) // Empty for parameter // Mismatche with basic types... :(
const send = newSynteticTVar() // Without send there is no instance
const instance = newSyntheticTVar().setType(new WollokParametricType(module)) // Empty for parameter // Mismatche with basic types... :(
const send = newSyntheticTVar() // Without send there is no instance
const newInstance = tVar.instanceFor(instance, send)

newInstance.should.not.be.eq(tVar) // New TVAR
Expand All @@ -302,24 +302,24 @@ describe('Wollok Type System', () => {
})

it('Not create new type variables if there is not new intances (optimised)', () => {
const newInstance = tVar.instanceFor(newSynteticTVar(), newSynteticTVar())
const newInstance = tVar.instanceFor(newSyntheticTVar(), newSyntheticTVar())
newInstance.should.be.eq(tVar)
})

})

it('Generic type string', () => {
const parametricType = new WollokParametricType(module, { 'param': newSynteticTVar().setType(stubType) })
const parametricType = new WollokParametricType(module, { 'param': newSyntheticTVar().setType(stubType) })
parametricType.name.should.be.eq(`${module.name}<${stubType.name}>`)
})

it('Method type string', () => {
const methodType = new WollokMethodType(newSynteticTVar().setType(stubType), [newSynteticTVar().setType(otherStubType)])
const methodType = new WollokMethodType(newSyntheticTVar().setType(stubType), [newSyntheticTVar().setType(otherStubType)])
methodType.name.should.be.eq(`(${otherStubType.name}) => ${stubType.name}`)

})
it('Closure type string', () => {
const closureType = new WollokClosureType(newSynteticTVar().setType(stubType), [newSynteticTVar().setType(otherStubType)], Closure({ code: 'TEST' }))
const closureType = new WollokClosureType(newSyntheticTVar().setType(stubType), [newSyntheticTVar().setType(otherStubType)], Closure({ code: 'TEST' }))
closureType.name.should.be.eq(`{ (${otherStubType.name}) => ${stubType.name} }`)
})

Expand Down

0 comments on commit 95e37df

Please sign in to comment.