Skip to content

Commit

Permalink
Fix empty tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-phillips committed Aug 28, 2024
1 parent 1de6b81 commit b62323b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ are ) in the codebase, as of the last time that I updated this list.

### Some other things I know are missing

- empty tuples are probably broken
- (EASY) I used parens instead of a `,` like a total python NOOB
- no let assert
- (EASY) const definitions aren't supported yet (module.constants)
- type aliases aren't supported yet (module.type_aliases)
- macabre_stdlib only has `io.println`
- Not doing anything to avoid collision between gleam identifiers with python keywords
- Especially: shadowed variable names behave differently if used in closures
- glance itself doesn't support comments, so these are stripped out of the compiled code
- glance doesn't have (much of) a typechecker
- the standard gleam LSP chokes on the fact that I don't have dependencies in hex
- not currently generating python type hints (e.g. function arguments and
return types), but gleam gives us that info so may as well use it
- No Result custom type yet (I thought this needed to be in the prelude, but I don't see any result-specific syntax anywhere)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/internal/generator/expressions.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn generate_expression(expression: python.Expression) -> StringBuilder {
expressions
|> internal.generate_plural(generate_expression, ", "),
)
|> string_builder.append(")")
|> string_builder.append(",)")

python.TupleIndex(expression, index) ->
generate_expression(expression)
Expand Down
6 changes: 3 additions & 3 deletions test/compiler/case_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main():
match _case_subject:
case (1, 2):
return \"one\"
return _fn_case_0((1, 2))",
return _fn_case_0((1, 2,))",
)
}

Expand Down Expand Up @@ -152,7 +152,7 @@ def main():
match _case_subject:
case (1, x):
return x + 50
return _fn_case_0((1, 2))",
return _fn_case_0((1, 2,))",
)
}

Expand Down Expand Up @@ -196,7 +196,7 @@ def main():
match _case_subject:
case (1, 2) | (2, 3):
return 5
return _fn_case_0((1, 2))",
return _fn_case_0((1, 2,))",
)
}

Expand Down
6 changes: 3 additions & 3 deletions test/compiler/expression_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn tuple_expression_test() {
"from gleam_builtins import *
def main():
return (42, 12.5, \"foo\")",
return (42, 12.5, \"foo\",)",
)
}

Expand Down Expand Up @@ -255,7 +255,7 @@ pub fn tuple_index_test() {
"from gleam_builtins import *
def main():
return (42, 12.5, \"foo\")[1]",
return (42, 12.5, \"foo\",)[1]",
)
}

Expand Down Expand Up @@ -675,7 +675,7 @@ def main():
pass
def _fn_def_1(c, d):
pass
foo = (_fn_def_0, _fn_def_1)",
foo = (_fn_def_0, _fn_def_1,)",
)
}

Expand Down

0 comments on commit b62323b

Please sign in to comment.