evhub / coconut

Simple, elegant, Pythonic functional programming.
http://coconut-lang.org
Apache License 2.0
4.04k stars 120 forks source link

Wrong f-string parsing and compile warning #840

Closed shilkazx closed 2 months ago

shilkazx commented 2 months ago

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.

evhub commented 2 months ago

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