Skip to content

Commit

Permalink
Merge pull request #26 from GoNZooo/r.fix-type-variables-shadowing-de…
Browse files Browse the repository at this point in the history
…finition-reference-parsing

fix: fix type parameter having higher priority than definition references
  • Loading branch information
GoNZooo authored Oct 3, 2022
2 parents 893eb00 + 00bd04f commit 89738b4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions gotyno-hs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extra-source-files:
test/examples/relaxedWhiteSpace.gotyno
test/examples/result.gotyno
test/examples/tooManyAppliedImportedTypeParameters.gotyno
test/examples/typeVariableParsingAfterDefinitionReference.gotyno
test/examples/untaggedUnionValidator.gotyno
test/examples/untaggedUnionWithDeclaration.gotyno

Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: gotyno-hs
version: 1.2.16
version: 1.2.17
synopsis: A type definition compiler supporting multiple output languages.
description: Compiles type definitions into F#, TypeScript and Python, with validators, decoders and encoders.
license: BSD2
Expand Down
2 changes: 1 addition & 1 deletion src/Parsing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ fieldTypeP imports typeVariables =
choice
[ LiteralType <$> literalP,
ComplexType <$> complexTypeP imports typeVariables,
TypeVariableReferenceType <$> typeVariableReferenceP typeVariables,
DefinitionReferenceType <$> definitionReferenceP imports typeVariables,
TypeVariableReferenceType <$> typeVariableReferenceP typeVariables,
BasicType <$> basicTypeValueP,
DefinitionReferenceType <$> importedReferenceP imports typeVariables,
RecursiveReferenceType <$> recursiveReferenceP
Expand Down
5 changes: 5 additions & 0 deletions test/ParsingSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ spec
]
isLeft result `shouldBe` True

describe "Type parameter regression tests" $ do
it "Should be able to parse definition name when it starts with a type parameter char" $ do
result <- parseModules ["test/examples/typeVariableParsingAfterDefinitionReference.gotyno"]
shouldBeRight result

describe "Reference output" $ do
it "Gives the correct parsed output for `basic.gotyno`" $ do
Module {_moduleName = name, _moduleImports = imports, _moduleDefinitions = definitions} <-
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
struct TStruct {
field: U32
}

struct GenericStruct <T>{
field: TStruct
}

0 comments on commit 89738b4

Please sign in to comment.