Skip to content

Commit d5b651c

Browse files
committed
Pass null as flag decoder when flag is Bytes
1 parent 04299ea commit d5b651c

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

compiler/src/AST/Optimized.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ data Main
127127
| StaticVDom
128128
| Dynamic
129129
{ _message :: Can.Type,
130+
_isBytes :: Bool,
130131
_decoder :: Expr
131132
}
132133

@@ -349,15 +350,15 @@ instance Binary Main where
349350
case main of
350351
StaticString -> putWord8 0
351352
StaticVDom -> putWord8 1
352-
Dynamic a b -> putWord8 2 >> put a >> put b
353+
Dynamic a b c -> putWord8 2 >> put a >> put b >> put c
353354

354355
get =
355356
do
356357
word <- getWord8
357358
case word of
358359
0 -> return StaticString
359360
1 -> return StaticVDom
360-
2 -> liftM2 Dynamic get get
361+
2 -> liftM3 Dynamic get get get
361362
_ -> fail "problem getting Opt.Main binary"
362363

363364
instance Binary Node where

compiler/src/Generate/JavaScript/Expression.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,12 @@ generateMain mode argLookup home main =
891891
Opt.StaticVDom ->
892892
JS.Ref (JsName.fromKernel Name.virtualDom "init")
893893
# JS.Ref (JsName.fromGlobal home "main")
894-
Opt.Dynamic _ decoder ->
894+
Opt.Dynamic _ False decoder ->
895895
JS.Ref (JsName.fromGlobal home "main")
896896
# generateJsExpr mode argLookup home decoder
897+
Opt.Dynamic _ True _ ->
898+
JS.Ref (JsName.fromGlobal home "main")
899+
# JS.Null
897900

898901
(#) :: JS.Expr -> JS.Expr -> JS.Expr
899902
(#) func arg =

compiler/src/Optimize/Module.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ addDefHelp platform region annotations home name args body graph@(Opt.LocalGraph
200200
Result.ok $
201201
addMain $
202202
Names.run $
203-
Opt.Dynamic message <$> Port.toFlagsDecoder flags
203+
Opt.Dynamic message (Port.isBytes flags) <$> Port.toFlagsDecoder flags
204204
Left (subType, invalidPayload) ->
205205
Result.throw (E.BadFlags region subType invalidPayload)
206206
_ ->

0 commit comments

Comments
 (0)