Skip to content

Implement generic function calls and declarations - #442

Merged
CohenArthur merged 30 commits into
masterfrom
function-call-generics-pass
Dec 28, 2021
Merged

CohenArthur merged 30 commits into
masterfrom
function-call-generics-pass

Conversation

@CohenArthur

Copy link
Copy Markdown
Member

No description provided.

@CohenArthur
CohenArthur force-pushed the function-call-generics-pass branch from ea1570e to 1bed0fa Compare December 26, 2021 18:40
@CohenArthur

Copy link
Copy Markdown
Member Author
func id[T](x: T) -> T { x }

id[string]("hey")
id[float](15.4)

b = true

func ret_bool() -> bool {
    {
        if b {
            b
        } else {
            false
        }
    }
}

func returns_bool() -> bool {
    ret_bool()
}

if id[bool](returns_bool()) {
    println("Yay")
} else {
    println("Nay")
}

fails typechecking with the following error

Error type: Typechecker
 ===> test.jk
    |
    | if condition should be a boolean, not a `void`
    |

@CohenArthur

Copy link
Copy Markdown
Member Author

We probably need to add a new variant to checked type such as CheckedType::Later to indicate that typechecking cannot yet be performed. And get rid of CheckedType::Unknown as it is currently used for both the later and error "type checks"

@CohenArthur
CohenArthur force-pushed the function-call-generics-pass branch from 1bed0fa to d5784ad Compare December 27, 2021 09:45
@CohenArthur
CohenArthur force-pushed the function-call-generics-pass branch from d5784ad to 6fb503b Compare December 27, 2021 22:40
@CohenArthur
CohenArthur force-pushed the function-call-generics-pass branch from 61c67c9 to a524ad7 Compare December 27, 2021 23:11
@CohenArthur

Copy link
Copy Markdown
Member Author

This PR should stay up while we iron out the different ways to actually obtain generic function calls. Passing the three easy tests in generics.yml should be split in a few PRs and should already be a good start

@CohenArthur
CohenArthur force-pushed the function-call-generics-pass branch from a524ad7 to 01672c8 Compare December 27, 2021 23:18
@CohenArthur

Copy link
Copy Markdown
Member Author

I think the only missing piece for a correct base is to fix #459

@CohenArthur
CohenArthur marked this pull request as ready for review December 28, 2021 17:11
@CohenArthur
CohenArthur merged commit 7263a46 into master Dec 28, 2021
@CohenArthur
CohenArthur deleted the function-call-generics-pass branch December 28, 2021 17:20
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.

1 participant