Skip to content

Commit bf01923

Browse files
Bump version and bug fixes
1 parent f9bbc0d commit bf01923

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

RELEASE_NOTES_COMPILER.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 0.7.33
2+
3+
* Add operator `enum`
4+
15
### 0.7.32
26

37
* Fixed default comparer: PR #658

RELEASE_NOTES_CORE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 0.7.24
2+
3+
* Fixed serialization of maps with string keys: #659
4+
15
### 0.7.23
26

37
* Added BigInt conversions: PR #650

src/fable/Fable.Compiler/Replacements.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ module private AstPass =
681681
| "toSingle" | "toDouble" | "toDecimal" -> toFloat com info args |> Some
682682
| "toChar" -> toChar com info args.Head |> Some
683683
| "toString" -> toString com info args.Head |> Some
684+
| "toEnum" -> args.Head |> Some
684685
| "createDictionary" ->
685686
GlobalCall("Map", None, true, args) |> makeCall r typ |> Some
686687
| "createSet" ->

src/fable/Fable.Core/ts/Serialize.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ export function toJson(o: any): string {
2525
return Array.from(v);
2626
}
2727
else if (v instanceof FableMap || v instanceof Map) {
28+
let stringKeys: boolean = null;
2829
return fold((o: any, kv: [any,any]) => {
29-
return o[toJson(kv[0])] = kv[1], o;
30+
if (stringKeys === null) {
31+
stringKeys = typeof kv[0] === "string";
32+
}
33+
o[stringKeys ? kv[0] : toJson(kv[0])] = kv[1];
34+
return o;
3035
}, {}, v);
3136
}
3237
else if (!hasInterface(v, "FSharpRecord") && properties) {

src/tests/Main/EnumTests.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ let ``EnumOfValue works``() =
107107
EnumOfValue 2 |> equal Fruits.Banana
108108
EnumOfValue 3 |> equal Fruits.Coconut
109109

110+
[<Test>]
111+
let ``Enum operator enum works``() =
112+
enum 1 |> equal Fruits.Apple
113+
enum 2 |> equal Fruits.Banana
114+
enum 3 |> equal Fruits.Coconut
115+
110116
open LanguagePrimitives
111117

112118
type Vegetables =

src/tests/Main/JsonTests.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ let ``Maps`` () =
293293
result.a.Count |> equal 2
294294
result.a.["b"] = { a="bb"; b=2 } |> equal true
295295

296+
[<Test>]
297+
let ``Map string keys are not quoted``() = // #659
298+
let v = [ "foo", 1 ] |> Map.ofList
299+
let serialised = toJson v
300+
(toJson v).Replace(" ", "") |> equal """{"foo":1}"""
301+
296302
type DictionaryJson =
297303
{ a: System.Collections.Generic.Dictionary<string, Child> }
298304

0 commit comments

Comments
 (0)