Skip to content

Commit

Permalink
F#: Chars can only contain one character (#1570)
Browse files Browse the repository at this point in the history
This PR fixes #1480.
  • Loading branch information
RunDevelopment authored and mAAdhaTTah committed Sep 23, 2018
1 parent bfa5a8d commit f96b083
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/prism-fsharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Prism.languages.fsharp = Prism.languages.extend('clike', {
],
'keyword': /\b(?:let|return|use|yield)(?:!\B|\b)|\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|select|static|struct|then|to|true|try|type|upcast|val|void|when|while|with|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/,
'string': {
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1)B?/,
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|"(?:\\[\s\S]|[^\\"])*")B?|'(?:[^\\']|\\.)'B?/,
greedy: true
},
'number': [
Expand Down
2 changes: 1 addition & 1 deletion components/prism-fsharp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions tests/languages/fsharp/issue1480.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
let foo' = failWith "foo"

let bar' = failWith "bar"

let map (f: 'a -> 'b) (xs: 'a list): 'b list = failWith "not implemented"

----------------------------------------------------

[
["keyword", "let"], " foo' ", ["operator", "="], " failWith ", ["string", "\"foo\""],
["keyword", "let"], " bar' ", ["operator", "="], " failWith ", ["string", "\"bar\""],

["keyword", "let"],
" map ",
["punctuation", "("],
"f",
["punctuation", ":"],
" 'a ",
["operator", "-"],
["operator", ">"],
" 'b",
["punctuation", ")"],
["punctuation", "("],
"xs",
["punctuation", ":"],
" 'a list",
["punctuation", ")"],
["punctuation", ":"],
" 'b list ",
["operator", "="],
" failWith ",
["string", "\"not implemented\""]
]

----------------------------------------------------

Checks for apostrophes in names. See #1480.
2 changes: 2 additions & 0 deletions tests/languages/fsharp/string_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bar"""
"""foo"""B

'a'
'a'B
'\''
'\\'

Expand All @@ -36,6 +37,7 @@ bar"""
["string", "\"\"\"foo\"\"\"B"],

["string", "'a'"],
["string", "'a'B"],
["string", "'\\''"],
["string", "'\\\\'"]
]
Expand Down

0 comments on commit f96b083

Please sign in to comment.