Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 521

Problem with building with dune: Unbound module

$
0
0

Hi! I’m having a problem with dune, when building and running tests on it.

I’m using dune 2.9.1.

Here is the brief structure of my project.

├── dune-project
├── src
│  ├── dune
│  ├── lexer.mll
│  ├── parser.mly
│  ├── parser_interface.ml
│  ├── syntax.ml
│  └── type.ml
├── test
│  ├── dune
│  └── parsing_test.ml
└── titan.opam

I’d like to run this test in parsing_test.ml.

open OUnit2
open Titan.Parser_interface
open Titan.Syntax

let peq (s : string) (v : 'a) = assert_equal v (parse_program s)

let test_parse_int_constants _ =
  peq "0" (Syntax.program [ IntLiteral 0 ]);
  peq "123" (Syntax.program [ IntLiteral 123 ])
;;

However, I got an error like this.

dune runtest
File "test/parsing_test.ml", line 8, characters 11-25:
8 |   peq "0" (Syntax.program [ IntLiteral 0 ]);
               ^^^^^^^^^^^^^^
Error: Unbound module Syntax

The content of test/dune is like this.

(library
 (name titan_test)
 (libraries base core stdio titan ounit2)
 (inline_tests)
 (preprocess
  (pps ppx_jane)))

The content of src/dune is like this.

(library
 (name titan)
 (libraries base stdio))

(menhir
 (modules parser))

(ocamllex
 (modules lexer))

src/syntax.ml is like this.

(* indentifier for variables *)
type id = string

(* brackets *)
type brackets =
  | Lparen
  | Rparen

(* binary operator *)
type binOp =
  | Plus
  | Minus
  | Mult
  | Div
  | Eq
  | Neq
  | Less
  | Leq
  | Greater
  | Geq
  | And
  | Or
  | Xor
  | Nor
  | Nand

(* unary operator *)
type unOp =
  | Excl
  | Not

(* expressions *)
type exp =
  | Var of id
  | IntLiteral of int
  | BoolLiteral of bool
  | StringLiteral of string
  | BinOp of binOp * exp * exp
  | UnOp of unOp * exp
  | IfExp of exp * exp * exp
  | LetExp of id * exp * exp

(* program *)
type program = Exp of exp list

(* type *)
type tyvar = int

type ty =
  | TyVar of tyvar
  | TyInt
  | TyBool
  | TyFun of ty * ty
  | TypList of ty

How should I fix this error? Any help is welcome!

3 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 521

Trending Articles