idris-lang / Idris-dev

A Dependently Typed Functional Programming Language
http://idris-lang.org
Other
3.43k stars 643 forks source link

Library names in package files may not contain hyphens #4292

Open ianbollinger opened 6 years ago

ianbollinger commented 6 years ago

idris --build will terminate with an error if an .ipkg file references a library with a hyphen in its name. Presumably it will fail for other valid file names, but I haven't investigated yet.

Steps to Reproduce

A minimal .ipkg file that produces the error:

package example
libs = example-1.0
modules = Example

Expected Behavior

The package links successfully.

Observed Behavior

$ idris --build example.ipkg
Uncaught error: user error (example.ipkg:2:15:
  |
2 | libs = example-1.0
  |               ^
unexpected '-'
expecting "author", "brief", "bugtracker", "executable", "homepage", "libs", "license", "main", "maintainer", "makefile", "modules", "objs", "opts", "pkgs", "readme", "sourcedir", "sourceloc", "tests", "version", ',', or end of input
)

Workaround

package example
opts = "--cg-opt='-L example-1.0"
modules = Example

Comments

I'm guessing this is a relatively trivial fix, so I'll take a look at fixing it shortly. I just wanted to document it in case I forgot about it.

ahmadsalim commented 6 years ago

Thanks for reporting the issue. PRs more than welcome!

luc-tielen commented 6 years ago

Something like the following? Can't test it right now:

diff --git a/src/Idris/Parser/Helpers.hs b/src/Idris/Parser/Helpers.hs
index 25a41ea7..704a6903 100644
--- a/src/Idris/Parser/Helpers.hs
+++ b/src/Idris/Parser/Helpers.hs
@@ -271,7 +271,7 @@ reservedIdentifiers = HS.fromList
 identifierOrReserved :: Parsing m => m String
 identifierOrReserved = token $ P.try $ do
   c <- P.satisfy isAlpha <|> P.oneOf "_"
-  cs <- P.many (P.satisfy isAlphaNum <|> P.oneOf "_'.")
+  cs <- P.many (P.satisfy isAlphaNum <|> P.oneOf "_'-.")
   return $ c : cs

 char :: Parsing m => Char -> m Char

Maybe a more sophisticated fix is needed so - is not allowed at end?

unalos commented 5 years ago
.\Data\Complex.idr:58:25-46:
724   |
72558 |     (*) (a:+b) (c:+d) = ((a*c-b*d):+(b*c+a*d))
726   |                         ~~~~~~~~~~~~~~~~~~~~~~
727When checking right hand side of Prelude.Interfaces.Data.Complex.Complex a implementation of Prelude.Interfaces.Num, method * with expected type
728        Complex a

The proposed fix is too wide and impacts parsing of numerical operators. I've narrowed it.

Pull request #4623

foolswood commented 5 years ago

@unalos should this issue be closed as having been resolved?