@@ -68,11 +68,13 @@ export function list_into(Type) {
6868 let invalid_selector_found =
6969 selector instanceof FTL . MessageReference
7070 || selector instanceof FTL . TermReference
71+ || ( selector instanceof FTL . CallExpression
72+ && selector . callee instanceof FTL . TermReference )
7173 || selector instanceof FTL . VariantExpression
7274 || ( selector instanceof FTL . AttributeExpression
7375 && selector . ref instanceof FTL . MessageReference ) ;
7476 if ( invalid_selector_found ) {
75- return never ( " Invalid selector type: ${selector.type}." ) ;
77+ return never ( ` Invalid selector type: ${ selector . type } .` ) ;
7678 }
7779 let invalid_variants_found = variants . some (
7880 variant => variant . value instanceof FTL . VariantList ) ;
@@ -94,14 +96,24 @@ export function list_into(Type) {
9496
9597export function into ( Type ) {
9698 switch ( Type ) {
99+ case FTL . FunctionReference :
100+ const FUNCTION_NAME = / ^ [ A - Z ] [ A - Z 0 - 9 _ ? - ] * $ / ;
101+ return identifier => {
102+ if ( ! FUNCTION_NAME . test ( identifier . name ) ) {
103+ return never (
104+ "Function names must be upper-case: " +
105+ `${ identifier . name } .` ) ;
106+ }
107+ return always ( new Type ( identifier ) ) ;
108+ } ;
97109 case FTL . Placeable :
98110 return expression => {
99111 let invalid_expression_found =
100112 expression instanceof FTL . AttributeExpression
101113 && expression . ref instanceof FTL . TermReference ;
102114 if ( invalid_expression_found ) {
103115 return never (
104- " Invalid expression type: ${expression.type}." ) ;
116+ ` Invalid expression type: ${ expression . type } .` ) ;
105117 }
106118 return always ( new Type ( expression ) ) ;
107119 } ;
0 commit comments