Skip to content

Commit

Permalink
Fix elm#1533, parsing upper case hex digits
Browse files Browse the repository at this point in the history
The check for upper case letters A-F had a comparison going the wrong
way. Rewrote to make it more clear.
  • Loading branch information
evancz committed Dec 19, 2016
1 parent 47e71ba commit 0c6152d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Parse/Primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ isHex word =
{-# INLINE isCapHex #-}
isCapHex :: Word16 -> Bool
isCapHex word =
word <= 0x0046 {- F -} && word <= 0x0041 {- A -}
0x0041 {- A -} <= word && word <= 0x0046 {- F -}


{-# INLINE readInt #-}
Expand Down
14 changes: 14 additions & 0 deletions tests/test-files/good-expected-js/Literals/Numbers.elm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var _elm_lang$core$Main$hex5 = 1193865;
var _elm_lang$core$Main$hex4 = 48879;
var _elm_lang$core$Main$hex3 = 48879;
var _elm_lang$core$Main$hex2 = 64;
var _elm_lang$core$Main$hex1 = 4294967295;
var _elm_lang$core$Main$float4 = 2300.0;
var _elm_lang$core$Main$float3 = 6.022e26;
var _elm_lang$core$Main$float2 = 0.67;
var _elm_lang$core$Main$float1 = 3.14;
var _elm_lang$core$Main$exp4 = 1000.0;
var _elm_lang$core$Main$exp3 = 2.0e-9;
var _elm_lang$core$Main$exp2 = 3.0e7;
var _elm_lang$core$Main$exp1 = 4.0e9;
var _elm_lang$core$Main$int = 12345;
18 changes: 18 additions & 0 deletions tests/test-files/good/Literals/Numbers.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

int = 12345

exp1 = 4e9
exp2 = 3E7
exp3 = 2e-9
exp4 = 1E+3

float1 = 3.14
float2 = 0.67
float3 = 6.022e26
float4 = 0.23E4

hex1 = 0xFFFFFFFF
hex2 = 0x0040
hex3 = 0xbeef
hex4 = 0xBEEF
hex5 = 0x0123789

0 comments on commit 0c6152d

Please sign in to comment.