Skip to content

Commit

Permalink
fix dumb optional arg codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiayang committed Oct 11, 2019
1 parent 6a974fb commit 6c241db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions build/ultratiny.flx
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,25 @@ class B : A

// issue #0: we basically don't really even check for overriding methods properly.
// issue #1: co/contra-variance of return and parameter types for virtual methods
// issue #2: crashes when initialisers have default arguments??
// issue #2: crashes when functions have default arguments??

// classes are a Bad Idea (tm) ):

struct Tmp
class Tmp
{
k: int
m: int
var z: int

fn meth() -> int => k * m
init(x: int = 3, y: int = 7)
{
this.z = x * y
}
}


@entry fn main()
{
fn foo(x: int = 3, y: int = 7) -> int => x * y

// let a = B()
// let q = a.foo(Y(c: 1)).data

Expand All @@ -109,6 +114,8 @@ struct Tmp
// let q = Tmp(k: 3, m: 7).meth()

// let q = B().foo(Y(c: 1)).data

let q = foo(x: 7)
std::io::println("thing: %", q)
}

Expand Down
2 changes: 1 addition & 1 deletion source/codegen/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static std::vector<fir::Value*> _codegenAndArrangeFunctionCallArguments(cgn::Cod
for(size_t i = 0; i < argExprs.size(); i++)
{
// this extra complexity is to ensure we codegen arguments from left-to-right!
auto arg = arguments[i].value;
auto arg = argExprs[i];
auto k = revArgExprs[arg];

auto infer = ft->getArgumentN(k);
Expand Down

0 comments on commit 6c241db

Please sign in to comment.