flix icon indicating copy to clipboard operation
flix copied to clipboard

feat: require escaping keyword names

Open JonathanStarup opened this issue 9 months ago • 10 comments

x.and(y) now needs to be

x.`and`(y)

Concerns and missing things:

  • Should it be an error to escape a non-keyword?
  • Static fields and methods cannot use escapes (Hello.thing is parsed in general, before knowing whether it is a java thing)

Fixes #10002 Fixes #9213

JonathanStarup avatar Mar 02 '25 16:03 JonathanStarup

PR Lexer: 216,1 ms (06,9%) Master Lexer: 193,3 ms (06,2%)

I don't see why the lexer would be slower, seems weird

JonathanStarup avatar Mar 02 '25 16:03 JonathanStarup

@mlutze Can you review and then I will?

magnus-madsen avatar Mar 02 '25 16:03 magnus-madsen

I'm not sure this should be merged as is - we should probably think about static names. and what about importing MyClass.{and => myAnd} fx

We should figure out all the places where keyword escapes are needed

JonathanStarup avatar Mar 02 '25 16:03 JonathanStarup

Hmm. True.

magnus-madsen avatar Mar 02 '25 16:03 magnus-madsen

You cannot import methods though

magnus-madsen avatar Mar 02 '25 16:03 magnus-madsen

Ah okay, so its mostly Math.and or whatever might static things there might be

JonathanStarup avatar Mar 02 '25 19:03 JonathanStarup

Marked as draft until completed.

magnus-madsen avatar Mar 02 '25 19:03 magnus-madsen

String.trim is parsed the same as System.out - allowing static Java things to use escapes means we must allow all(?) QNames to use escapes and then later (after knowing the types) disallow escaping Flix names.

JonathanStarup avatar Mar 03 '25 11:03 JonathanStarup

This still alive?

mlutze avatar Jun 19 '25 05:06 mlutze

I guess so yeah

JonathanStarup avatar Jun 19 '25 09:06 JonathanStarup

My impression is that a clean design is needed... and then some manpower to implement it.

Could be part of a lexer re-implementation.

magnus-madsen avatar Jul 07 '25 10:07 magnus-madsen