Skip to content

compiler: fix comp. of func calls for func values of a defined type #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2019

Conversation

knieriem
Copy link
Contributor

@knieriem knieriem commented May 3, 2019

When compiling a piece of code where a function value is called,
the compiler panics if the function value's type is a defined type,
and not just a type literal (function signature): The type assertion
(*types.Signature) fails, because the type of the func value is a
*types.Named.

This patch fixes this by using the type's underlying type, so that a
types.Named is properly turned into its underlying types.Signature,
before the type assertion takes place.
It takes advantage of the property that all types have an underlying type
(both are the same, if a type is not named).

Fixes #320

When compiling a piece of code where a function value is called,
the compiler panics if the function value's type is a defined type,
and not just a type literal (function signature): The type assertion
(*types.Signature) fails, because the type of the func value is a
*types.Named.

This patch fixes this by using the type's underlying type, so that a
types.Named is properly turned into its underlying types.Signature,
before the type assertion takes place.
It takes advantage of the property that all types have an underlying type
(both are the same, if a type is not named).

Fixes tinygo-org#320
@aykevl aykevl merged commit 7e46c17 into tinygo-org:dev May 3, 2019
@aykevl
Copy link
Member

aykevl commented May 3, 2019

Thank you for this fix!

directionless added a commit to directionless/tinygo that referenced this pull request May 9, 2019
Tests for tinygo-org#322

(And a .gitignore addition for llvm)
directionless added a commit to directionless/tinygo that referenced this pull request May 9, 2019
Tests for tinygo-org#322

(And a .gitignore addition for llvm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants