evhub / coconut

Simple, elegant, Pythonic functional programming.

Home Page:http://coconut-lang.org

Repository from Github https://github.comevhub/coconutRepository from Github https://github.comevhub/coconut

Wrong f-string parsing and compile warning

shilkazx opened this issue · comments

commented

coconut v3.1.0 with python v3.9.18
coconut can not parse multi-line f-string properly. It will remove 'f' before the multi-line string and the compiled code is wrong.
e.g.
coconut code:

sql = f'''SELECT * 
                FROM SOME_TABLE
                WHERE CODE = '{self.code}' '''

compile this code would raise warning:
CoconutSyntaxWarning: f-string with no expressions (line xxx in 'xxx.coco')
and the compiled code is:

sql = '''SELECT * 
                FROM SOME_TABLE
                WHERE CODE = '{self.code}' '''.format()

This code is totally wrong. Coconut should just copy the original code snippet in the generated python file.

Looks like a duplicate of #839, which should already be resolved on coconut-develop. Try pip uninstall coconut && pip install -U coconut-develop.