Skip to content

Commit

Permalink
Merge pull request #205 from riantkb/fix-202
Browse files Browse the repository at this point in the history
fix(cxx): Always add int64 suffix to int64 literals
  • Loading branch information
kmyk authored Sep 1, 2021
2 parents 838de02 + c85d23e commit a4bd873
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/Jikka/CPlusPlus/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ formatType = \case
formatLiteral :: Literal -> Code
formatLiteral = \case
LitInt32 n -> show n
LitInt64 n
| - (2 ^ 31) <= n && n < 2 ^ 31 -> show n
| otherwise -> show n ++ "ll"
LitInt64 n -> show n ++ "ll"
LitBool p -> if p then "true" else "false"
LitChar c -> show c
LitString s -> show s
Expand Down
4 changes: 2 additions & 2 deletions test/Jikka/CPlusPlus/FormatSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec = do
]
let formatted =
[ "int64_t solve(int32_t n) {",
" int64_t x = 0;",
" int64_t x = 0ll;",
" for (int32_t i = 0; i < n; ++ i) {",
" x += int64_t(i);",
" }",
Expand Down Expand Up @@ -65,7 +65,7 @@ spec = do
]
let formatted =
[ "int64_t solve(int32_t n, std::vector<int64_t> h) {",
" int64_t x = 0;",
" int64_t x = 0ll;",
" for (int32_t i = 2; i < n; ++ i) {",
" x += h[i - 2];",
" }",
Expand Down

0 comments on commit a4bd873

Please sign in to comment.