Skip to content

Commit 77f9433

Browse files
committed
Avoid stringHead of an empty string
1 parent 9381a58 commit 77f9433

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Libraries/Base1/Prelude.bs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4530,7 +4530,9 @@ instance (SplitPorts a p, TupleSize p n, WrapPorts p pb, WrapMethod b v, Curry (
45304530

45314531
methodArgBaseNames _ prefix (Cons h t) i = Cons
45324532
-- arg_names can start with a digit
4533-
(if prefix == "" && not (isDigit $ stringHead h) then h else prefix +++ "_" +++ h)
4533+
(if prefix == "" && (h == "" || not (isDigit $ stringHead h))
4534+
then h
4535+
else prefix +++ "_" +++ h)
45344536
(methodArgBaseNames (_ :: b) prefix t $ i + 1)
45354537
methodArgBaseNames _ prefix Nil i = Cons
45364538
(prefix +++ "_" +++ integerToString i)

src/Libraries/Base1/SplitPorts.bs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ instance (ShallowSplitPorts' r p) => ShallowSplitPorts' (Meta (MetaField name id
6969
shallowUnsplitPorts' = Meta ∘ shallowUnsplitPorts'
7070
shallowSplitPortNames' _ base = shallowSplitPortNames' (_ :: r) $
7171
-- Avoid an extra underscore, since data fields names are _[0-9]+
72-
if stringHead (stringOf name) == '_'
72+
if stringOf name == "" || stringHead (stringOf name) == '_'
7373
then base +++ stringOf name
7474
else base +++ "_" +++ stringOf name
7575

@@ -180,7 +180,7 @@ instance (DeepSplitPorts'' r p) => DeepSplitPorts'' (Meta (MetaField name idx) r
180180
deepUnsplitPorts'' = Meta ∘ deepUnsplitPorts''
181181
deepSplitPortNames'' _ base = deepSplitPortNames'' (_ :: r) $
182182
-- Avoid an extra underscore, since data fields names are _[0-9]+
183-
if stringHead (stringOf name) == '_'
183+
if stringOf name == "" || stringHead (stringOf name) == '_'
184184
then base +++ stringOf name
185185
else base +++ "_" +++ stringOf name
186186

0 commit comments

Comments
 (0)